mirror of https://github.com/ppy/osu
Populate hit offsets from score processor
This commit is contained in:
parent
f9db37a1de
commit
900da88498
|
@ -0,0 +1,23 @@
|
|||
// 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 osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Judgements
|
||||
{
|
||||
public class OsuHitCircleJudgementResult : OsuJudgementResult
|
||||
{
|
||||
public HitCircle HitCircle => (HitCircle)HitObject;
|
||||
|
||||
public Vector2? HitPosition;
|
||||
public float? Radius;
|
||||
|
||||
public OsuHitCircleJudgementResult(HitObject hitObject, Judgement judgement)
|
||||
: base(hitObject, judgement)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,11 @@
|
|||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
|
@ -32,6 +35,8 @@ public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithPro
|
|||
|
||||
protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle;
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
public DrawableHitCircle(HitCircle h)
|
||||
: base(h)
|
||||
{
|
||||
|
@ -86,6 +91,13 @@ private void load()
|
|||
AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue, true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
}
|
||||
|
||||
public override double LifetimeStart
|
||||
{
|
||||
get => base.LifetimeStart;
|
||||
|
@ -126,7 +138,19 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
|
|||
return;
|
||||
}
|
||||
|
||||
ApplyResult(r => r.Type = result);
|
||||
ApplyResult(r =>
|
||||
{
|
||||
var circleResult = (OsuHitCircleJudgementResult)r;
|
||||
|
||||
if (result != HitResult.Miss)
|
||||
{
|
||||
var localMousePosition = ToLocalSpace(inputManager.CurrentState.Mouse.Position);
|
||||
circleResult.HitPosition = HitObject.StackedPosition + (localMousePosition - DrawSize / 2);
|
||||
circleResult.Radius = (float)HitObject.Radius;
|
||||
}
|
||||
|
||||
circleResult.Type = result;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void UpdateInitialTransforms()
|
||||
|
@ -172,6 +196,8 @@ protected override void UpdateStateTransforms(ArmedState state)
|
|||
|
||||
public Drawable ProxiedLayer => ApproachCircle;
|
||||
|
||||
protected override JudgementResult CreateResult(Judgement judgement) => new OsuHitCircleJudgementResult(HitObject, judgement);
|
||||
|
||||
public class HitReceptor : CompositeDrawable, IKeyBindingHandler<OsuAction>
|
||||
{
|
||||
// IsHovered is used
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
// 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 osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Scoring
|
||||
{
|
||||
public class HitOffset
|
||||
{
|
||||
public readonly Vector2 Position1;
|
||||
public readonly Vector2 Position2;
|
||||
public readonly Vector2 HitPosition;
|
||||
public readonly float Radius;
|
||||
|
||||
public HitOffset(Vector2 position1, Vector2 position2, Vector2 hitPosition, float radius)
|
||||
{
|
||||
Position1 = position1;
|
||||
Position2 = position2;
|
||||
HitPosition = hitPosition;
|
||||
Radius = radius;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,11 +2,15 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Scoring
|
||||
{
|
||||
|
@ -28,6 +32,7 @@ public class OsuScoreProcessor : ScoreProcessor
|
|||
private const int timing_distribution_centre_bin_index = timing_distribution_bins;
|
||||
|
||||
private TimingDistribution timingDistribution;
|
||||
private readonly List<HitOffset> hitOffsets = new List<HitOffset>();
|
||||
|
||||
public override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
|
@ -39,6 +44,8 @@ public override void ApplyBeatmap(IBeatmap beatmap)
|
|||
base.ApplyBeatmap(beatmap);
|
||||
}
|
||||
|
||||
private OsuHitCircleJudgementResult lastCircleResult;
|
||||
|
||||
protected override void OnResultApplied(JudgementResult result)
|
||||
{
|
||||
base.OnResultApplied(result);
|
||||
|
@ -47,6 +54,8 @@ protected override void OnResultApplied(JudgementResult result)
|
|||
{
|
||||
int binOffset = (int)(result.TimeOffset / timingDistribution.BinSize);
|
||||
timingDistribution.Bins[timing_distribution_centre_bin_index + binOffset]++;
|
||||
|
||||
addHitOffset(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,17 +67,67 @@ protected override void OnResultReverted(JudgementResult result)
|
|||
{
|
||||
int binOffset = (int)(result.TimeOffset / timingDistribution.BinSize);
|
||||
timingDistribution.Bins[timing_distribution_centre_bin_index + binOffset]--;
|
||||
|
||||
removeHitOffset(result);
|
||||
}
|
||||
}
|
||||
|
||||
private void addHitOffset(JudgementResult result)
|
||||
{
|
||||
if (!(result is OsuHitCircleJudgementResult circleResult))
|
||||
return;
|
||||
|
||||
if (lastCircleResult == null)
|
||||
{
|
||||
lastCircleResult = circleResult;
|
||||
return;
|
||||
}
|
||||
|
||||
if (circleResult.HitPosition != null)
|
||||
{
|
||||
Debug.Assert(circleResult.Radius != null);
|
||||
hitOffsets.Add(new HitOffset(lastCircleResult.HitCircle.StackedEndPosition, circleResult.HitCircle.StackedEndPosition, circleResult.HitPosition.Value, circleResult.Radius.Value));
|
||||
}
|
||||
|
||||
lastCircleResult = circleResult;
|
||||
}
|
||||
|
||||
private void removeHitOffset(JudgementResult result)
|
||||
{
|
||||
if (!(result is OsuHitCircleJudgementResult circleResult))
|
||||
return;
|
||||
|
||||
if (hitOffsets.Count > 0 && circleResult.HitPosition != null)
|
||||
hitOffsets.RemoveAt(hitOffsets.Count - 1);
|
||||
}
|
||||
|
||||
protected override void Reset(bool storeResults)
|
||||
{
|
||||
base.Reset(storeResults);
|
||||
|
||||
timingDistribution.Bins.AsSpan().Clear();
|
||||
hitOffsets.Clear();
|
||||
}
|
||||
|
||||
protected override JudgementResult CreateResult(HitObject hitObject, Judgement judgement) => new OsuJudgementResult(hitObject, judgement);
|
||||
public override void PopulateScore(ScoreInfo score)
|
||||
{
|
||||
base.PopulateScore(score);
|
||||
|
||||
score.ExtraStatistics["timing_distribution"] = timingDistribution;
|
||||
score.ExtraStatistics["hit_offsets"] = hitOffsets;
|
||||
}
|
||||
|
||||
protected override JudgementResult CreateResult(HitObject hitObject, Judgement judgement)
|
||||
{
|
||||
switch (hitObject)
|
||||
{
|
||||
case HitCircle _:
|
||||
return new OsuHitCircleJudgementResult(hitObject, judgement);
|
||||
|
||||
default:
|
||||
return new OsuJudgementResult(hitObject, judgement);
|
||||
}
|
||||
}
|
||||
|
||||
public override HitWindows CreateHitWindows() => new OsuHitWindows();
|
||||
}
|
||||
|
|
|
@ -166,6 +166,8 @@ public string StatisticsJson
|
|||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, object> ExtraStatistics = new Dictionary<string, object>();
|
||||
|
||||
[JsonIgnore]
|
||||
public List<ScoreFileInfo> Files { get; set; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue