2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-06-15 21:44:55 +08:00
|
|
|
|
using System.Collections.Generic;
|
2020-06-18 21:11:03 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using JetBrains.Annotations;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2018-12-27 23:14:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2020-06-15 21:44:55 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-06-15 21:44:55 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2020-06-18 21:11:03 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Scoring
|
|
|
|
|
{
|
2020-05-16 17:17:32 +08:00
|
|
|
|
public class OsuScoreProcessor : ScoreProcessor
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-06-18 21:11:03 +08:00
|
|
|
|
private readonly List<HitEvent> hitEvents = new List<HitEvent>();
|
|
|
|
|
private HitObject lastHitObject;
|
2020-06-15 21:44:55 +08:00
|
|
|
|
|
2020-06-02 22:38:24 +08:00
|
|
|
|
protected override void OnResultApplied(JudgementResult result)
|
|
|
|
|
{
|
|
|
|
|
base.OnResultApplied(result);
|
|
|
|
|
|
2020-06-18 21:11:03 +08:00
|
|
|
|
hitEvents.Add(new HitEvent(result.TimeOffset, result.Type, result.HitObject, lastHitObject, (result as OsuHitCircleJudgementResult)?.HitPosition));
|
|
|
|
|
lastHitObject = result.HitObject;
|
2020-06-02 22:38:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnResultReverted(JudgementResult result)
|
|
|
|
|
{
|
|
|
|
|
base.OnResultReverted(result);
|
|
|
|
|
|
2020-06-18 21:11:03 +08:00
|
|
|
|
hitEvents.RemoveAt(hitEvents.Count - 1);
|
2020-06-15 21:44:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-02 22:38:24 +08:00
|
|
|
|
protected override void Reset(bool storeResults)
|
|
|
|
|
{
|
|
|
|
|
base.Reset(storeResults);
|
|
|
|
|
|
2020-06-18 21:11:03 +08:00
|
|
|
|
hitEvents.Clear();
|
|
|
|
|
lastHitObject = null;
|
2020-06-02 22:38:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-15 21:44:55 +08:00
|
|
|
|
public override void PopulateScore(ScoreInfo score)
|
|
|
|
|
{
|
|
|
|
|
base.PopulateScore(score);
|
|
|
|
|
|
2020-06-18 21:11:03 +08:00
|
|
|
|
score.HitEvents.AddRange(hitEvents.Select(e => e).Cast<object>());
|
2020-06-15 21:44:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override JudgementResult CreateResult(HitObject hitObject, Judgement judgement)
|
|
|
|
|
{
|
|
|
|
|
switch (hitObject)
|
|
|
|
|
{
|
|
|
|
|
case HitCircle _:
|
|
|
|
|
return new OsuHitCircleJudgementResult(hitObject, judgement);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return new OsuJudgementResult(hitObject, judgement);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-27 23:14:00 +08:00
|
|
|
|
|
2019-01-03 12:57:56 +08:00
|
|
|
|
public override HitWindows CreateHitWindows() => new OsuHitWindows();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2020-06-18 21:11:03 +08:00
|
|
|
|
|
|
|
|
|
public readonly struct HitEvent
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The time offset from the end of <see cref="HitObject"/> at which the event occurred.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly double TimeOffset;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The hit result.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly HitResult Result;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The <see cref="HitObject"/> on which the result occurred.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly HitObject HitObject;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The <see cref="HitObject"/> occurring prior to <see cref="HitObject"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[CanBeNull]
|
|
|
|
|
public readonly HitObject LastHitObject;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The player's cursor position, if available, at the time of the event.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly Vector2? CursorPosition;
|
|
|
|
|
|
|
|
|
|
public HitEvent(double timeOffset, HitResult result, HitObject hitObject, [CanBeNull] HitObject lastHitObject, Vector2? cursorPosition)
|
|
|
|
|
{
|
|
|
|
|
TimeOffset = timeOffset;
|
|
|
|
|
Result = result;
|
|
|
|
|
HitObject = hitObject;
|
|
|
|
|
LastHitObject = lastHitObject;
|
|
|
|
|
CursorPosition = cursorPosition;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|