Store tracking history to slider judgement result instead

This commit is contained in:
Bartłomiej Dach 2024-02-29 12:11:50 +01:00
parent 1d1db951f0
commit 876b806423
No known key found for this signature in database
3 changed files with 28 additions and 5 deletions

View File

@ -0,0 +1,20 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Osu.Judgements
{
public class OsuSliderJudgementResult : OsuJudgementResult
{
public readonly Stack<(double time, bool tracking)> TrackingHistory = new Stack<(double, bool)>();
public OsuSliderJudgementResult(HitObject hitObject, Judgement judgement)
: base(hitObject, judgement)
{
TrackingHistory.Push((double.NegativeInfinity, false));
}
}
}

View File

@ -14,8 +14,10 @@
using osu.Framework.Layout;
using osu.Game.Audio;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Skinning.Default;
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
@ -27,6 +29,8 @@ public partial class DrawableSlider : DrawableOsuHitObject
{
public new Slider HitObject => (Slider)base.HitObject;
public new OsuSliderJudgementResult Result => (OsuSliderJudgementResult)base.Result;
public DrawableSliderHead HeadCircle => headContainer.Child;
public DrawableSliderTail TailCircle => tailContainer.Child;
@ -134,6 +138,8 @@ private void load()
}, true);
}
protected override JudgementResult CreateResult(Judgement judgement) => new OsuSliderJudgementResult(HitObject, judgement);
protected override void OnApply()
{
base.OnApply();

View File

@ -27,8 +27,6 @@ public partial class SliderInputManager : Component, IRequireHighFrequencyMouseP
[Resolved]
private IGameplayClock? gameplayClock { get; set; }
private readonly Stack<(double time, bool tracking)> trackingHistory = new Stack<(double, bool)>();
/// <summary>
/// The point in time after which we can accept any key for tracking. Before this time, we may need to restrict tracking to the key used to hit the head circle.
///
@ -219,6 +217,7 @@ private void updateTracking(bool isValidTrackingPosition)
{
if (gameplayClock?.IsRewinding == true)
{
var trackingHistory = slider.Result.TrackingHistory;
while (trackingHistory.TryPeek(out var historyEntry) && Time.Current < historyEntry.time)
trackingHistory.Pop();
@ -271,7 +270,7 @@ private void updateTracking(bool isValidTrackingPosition)
&& validTrackingAction;
if (wasTracking != Tracking)
trackingHistory.Push((Time.Current, Tracking));
slider.Result.TrackingHistory.Push((Time.Current, Tracking));
}
private OsuAction? getInitialHitAction() => slider.HeadCircle?.HitAction;
@ -293,8 +292,6 @@ private bool isValidTrackingAction(OsuAction action)
private void resetState(DrawableHitObject obj)
{
Tracking = false;
trackingHistory.Clear();
trackingHistory.Push((double.NegativeInfinity, false));
timeToAcceptAnyKeyAfter = null;
lastPressedActions.Clear();
screenSpaceMousePosition = null;