mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 01:33:12 +08:00
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.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -32,6 +35,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle;
|
protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle;
|
||||||
|
|
||||||
|
private InputManager inputManager;
|
||||||
|
|
||||||
public DrawableHitCircle(HitCircle h)
|
public DrawableHitCircle(HitCircle h)
|
||||||
: base(h)
|
: base(h)
|
||||||
{
|
{
|
||||||
@ -86,6 +91,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue, true);
|
AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
inputManager = GetContainingInputManager();
|
||||||
|
}
|
||||||
|
|
||||||
public override double LifetimeStart
|
public override double LifetimeStart
|
||||||
{
|
{
|
||||||
get => base.LifetimeStart;
|
get => base.LifetimeStart;
|
||||||
@ -126,7 +138,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
return;
|
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()
|
protected override void UpdateInitialTransforms()
|
||||||
@ -172,6 +196,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
public Drawable ProxiedLayer => ApproachCircle;
|
public Drawable ProxiedLayer => ApproachCircle;
|
||||||
|
|
||||||
|
protected override JudgementResult CreateResult(Judgement judgement) => new OsuHitCircleJudgementResult(HitObject, judgement);
|
||||||
|
|
||||||
public class HitReceptor : CompositeDrawable, IKeyBindingHandler<OsuAction>
|
public class HitReceptor : CompositeDrawable, IKeyBindingHandler<OsuAction>
|
||||||
{
|
{
|
||||||
// IsHovered is used
|
// IsHovered is used
|
||||||
|
23
osu.Game.Rulesets.Osu/Scoring/HitOffset.cs
Normal file
23
osu.Game.Rulesets.Osu/Scoring/HitOffset.cs
Normal file
@ -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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Osu.Judgements;
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Scoring
|
namespace osu.Game.Rulesets.Osu.Scoring
|
||||||
{
|
{
|
||||||
@ -28,6 +32,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
|||||||
private const int timing_distribution_centre_bin_index = timing_distribution_bins;
|
private const int timing_distribution_centre_bin_index = timing_distribution_bins;
|
||||||
|
|
||||||
private TimingDistribution timingDistribution;
|
private TimingDistribution timingDistribution;
|
||||||
|
private readonly List<HitOffset> hitOffsets = new List<HitOffset>();
|
||||||
|
|
||||||
public override void ApplyBeatmap(IBeatmap beatmap)
|
public override void ApplyBeatmap(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
@ -39,6 +44,8 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
|||||||
base.ApplyBeatmap(beatmap);
|
base.ApplyBeatmap(beatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OsuHitCircleJudgementResult lastCircleResult;
|
||||||
|
|
||||||
protected override void OnResultApplied(JudgementResult result)
|
protected override void OnResultApplied(JudgementResult result)
|
||||||
{
|
{
|
||||||
base.OnResultApplied(result);
|
base.OnResultApplied(result);
|
||||||
@ -47,6 +54,8 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
|||||||
{
|
{
|
||||||
int binOffset = (int)(result.TimeOffset / timingDistribution.BinSize);
|
int binOffset = (int)(result.TimeOffset / timingDistribution.BinSize);
|
||||||
timingDistribution.Bins[timing_distribution_centre_bin_index + binOffset]++;
|
timingDistribution.Bins[timing_distribution_centre_bin_index + binOffset]++;
|
||||||
|
|
||||||
|
addHitOffset(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,17 +67,67 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
|||||||
{
|
{
|
||||||
int binOffset = (int)(result.TimeOffset / timingDistribution.BinSize);
|
int binOffset = (int)(result.TimeOffset / timingDistribution.BinSize);
|
||||||
timingDistribution.Bins[timing_distribution_centre_bin_index + binOffset]--;
|
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)
|
protected override void Reset(bool storeResults)
|
||||||
{
|
{
|
||||||
base.Reset(storeResults);
|
base.Reset(storeResults);
|
||||||
|
|
||||||
timingDistribution.Bins.AsSpan().Clear();
|
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();
|
public override HitWindows CreateHitWindows() => new OsuHitWindows();
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,8 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, object> ExtraStatistics = new Dictionary<string, object>();
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<ScoreFileInfo> Files { get; set; }
|
public List<ScoreFileInfo> Files { get; set; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user