2019-01-24 08:43:03 +00: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-08-02 11:35:54 +00:00
|
|
|
|
2019-09-02 07:28:14 +00:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-08-06 01:55:38 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-08-02 11:35:54 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Judgements
|
|
|
|
{
|
2018-08-06 01:55:38 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The scoring result of a <see cref="DrawableHitObject"/>.
|
|
|
|
/// </summary>
|
2018-08-02 11:35:54 +00:00
|
|
|
public class JudgementResult
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Whether this <see cref="JudgementResult"/> is the result of a hit or a miss.
|
|
|
|
/// </summary>
|
|
|
|
public HitResult Type;
|
|
|
|
|
|
|
|
/// <summary>
|
2019-09-02 08:14:40 +00:00
|
|
|
/// The <see cref="HitObject"/> which was judged.
|
2018-08-02 11:35:54 +00:00
|
|
|
/// </summary>
|
2019-09-02 08:14:40 +00:00
|
|
|
[NotNull]
|
|
|
|
public readonly HitObject HitObject;
|
2018-08-02 11:35:54 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The <see cref="Judgement"/> which this <see cref="JudgementResult"/> applies for.
|
|
|
|
/// </summary>
|
2019-09-02 08:14:40 +00:00
|
|
|
[NotNull]
|
2018-08-02 11:35:54 +00:00
|
|
|
public readonly Judgement Judgement;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The offset from a perfect hit at which this <see cref="JudgementResult"/> occurred.
|
2018-08-06 01:55:38 +00:00
|
|
|
/// Populated when this <see cref="JudgementResult"/> is applied via <see cref="DrawableHitObject.ApplyResult"/>.
|
2018-08-02 11:35:54 +00:00
|
|
|
/// </summary>
|
|
|
|
public double TimeOffset { get; internal set; }
|
|
|
|
|
2020-11-04 07:04:15 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The absolute time at which this <see cref="JudgementResult"/> occurred.
|
|
|
|
/// Equal to the (end) time of the <see cref="HitObject"/> + <see cref="TimeOffset"/>.
|
|
|
|
/// </summary>
|
|
|
|
public double TimeAbsolute => HitObject.GetEndTime() + TimeOffset;
|
|
|
|
|
2018-08-02 11:35:54 +00:00
|
|
|
/// <summary>
|
2018-08-06 01:55:38 +00:00
|
|
|
/// The combo prior to this <see cref="JudgementResult"/> occurring.
|
2018-08-02 11:35:54 +00:00
|
|
|
/// </summary>
|
|
|
|
public int ComboAtJudgement { get; internal set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2018-08-06 01:55:38 +00:00
|
|
|
/// The highest combo achieved prior to this <see cref="JudgementResult"/> occurring.
|
2018-08-02 11:35:54 +00:00
|
|
|
/// </summary>
|
|
|
|
public int HighestComboAtJudgement { get; internal set; }
|
|
|
|
|
2019-04-22 08:51:43 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The health prior to this <see cref="JudgementResult"/> occurring.
|
|
|
|
/// </summary>
|
|
|
|
public double HealthAtJudgement { get; internal set; }
|
|
|
|
|
2019-08-09 03:29:58 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Whether the user was in a failed state prior to this <see cref="JudgementResult"/> occurring.
|
|
|
|
/// </summary>
|
|
|
|
public bool FailedAtJudgement { get; internal set; }
|
|
|
|
|
2018-08-02 11:35:54 +00:00
|
|
|
/// <summary>
|
2018-08-06 01:55:38 +00:00
|
|
|
/// Whether a miss or hit occurred.
|
2018-08-02 11:35:54 +00:00
|
|
|
/// </summary>
|
|
|
|
public bool HasResult => Type > HitResult.None;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether a successful hit occurred.
|
|
|
|
/// </summary>
|
2020-09-29 06:20:47 +00:00
|
|
|
public bool IsHit => Type.IsHit();
|
2018-08-02 11:35:54 +00:00
|
|
|
|
2018-08-06 01:55:38 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new <see cref="JudgementResult"/>.
|
|
|
|
/// </summary>
|
2019-09-02 08:14:40 +00:00
|
|
|
/// <param name="hitObject">The <see cref="HitObject"/> which was judged.</param>
|
2018-08-06 01:55:38 +00:00
|
|
|
/// <param name="judgement">The <see cref="Judgement"/> to refer to for scoring information.</param>
|
2019-09-02 08:14:40 +00:00
|
|
|
public JudgementResult([NotNull] HitObject hitObject, [NotNull] Judgement judgement)
|
2018-08-02 11:35:54 +00:00
|
|
|
{
|
2019-09-02 08:14:40 +00:00
|
|
|
HitObject = hitObject;
|
2018-08-02 11:35:54 +00:00
|
|
|
Judgement = judgement;
|
|
|
|
}
|
2019-02-21 12:22:16 +00:00
|
|
|
|
|
|
|
public override string ToString() => $"{Type} (Score:{Judgement.NumericResultFor(this)} HP:{Judgement.HealthIncreaseFor(this)} {Judgement})";
|
2018-08-02 11:35:54 +00:00
|
|
|
}
|
|
|
|
}
|