Reset ScoreProcessor from statistics replay frames

This commit is contained in:
Dan Balasescu
2022-01-31 18:54:23 +09:00
parent 39e1d65976
commit 4fb565e15f
5 changed files with 144 additions and 15 deletions

View File

@ -16,6 +16,7 @@ using osu.Game.Configuration;
using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.Input.Handlers;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
using static osu.Game.Input.Handlers.ReplayInputHandler;
@ -24,6 +25,11 @@ namespace osu.Game.Rulesets.UI
public abstract class RulesetInputManager<T> : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler, IHasRecordingHandler
where T : struct
{
private readonly Ruleset ruleset;
[Resolved(CanBeNull = true)]
private ScoreProcessor scoreProcessor { get; set; }
private ReplayRecorder recorder;
public ReplayRecorder Recorder
@ -51,6 +57,8 @@ namespace osu.Game.Rulesets.UI
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
{
this.ruleset = ruleset.CreateInstance();
InternalChild = KeyBindingContainer =
CreateKeyBindingContainer(ruleset, variant, unique)
.WithChild(content = new Container { RelativeSizeAxes = Axes.Both });
@ -66,17 +74,23 @@ namespace osu.Game.Rulesets.UI
public override void HandleInputStateChange(InputStateChangeEvent inputStateChange)
{
if (inputStateChange is ReplayStateChangeEvent<T> replayStateChanged)
switch (inputStateChange)
{
foreach (var action in replayStateChanged.ReleasedActions)
KeyBindingContainer.TriggerReleased(action);
case ReplayStateChangeEvent<T> stateChangeEvent:
foreach (var action in stateChangeEvent.ReleasedActions)
KeyBindingContainer.TriggerReleased(action);
foreach (var action in replayStateChanged.PressedActions)
KeyBindingContainer.TriggerPressed(action);
}
else
{
base.HandleInputStateChange(inputStateChange);
foreach (var action in stateChangeEvent.PressedActions)
KeyBindingContainer.TriggerPressed(action);
break;
case ReplayStatisticsFrameEvent statisticsStateChangeEvent:
scoreProcessor?.ResetFromReplayFrame(ruleset, statisticsStateChangeEvent.Frame);
break;
default:
base.HandleInputStateChange(inputStateChange);
break;
}
}