// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable disable using System; using JetBrains.Annotations; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Judgements { /// /// The scoring result of a . /// public class JudgementResult { /// /// Whether this is the result of a hit or a miss. /// public HitResult Type; /// /// The which was judged. /// [NotNull] public readonly HitObject HitObject; /// /// The which this applies for. /// [NotNull] public readonly Judgement Judgement; /// /// The time at which this occurred. /// Populated when this is applied via . /// /// /// This is used instead of to check whether this should be reverted. /// internal double? RawTime { get; set; } /// /// The offset of from the end time of , clamped by . /// public double TimeOffset { get => RawTime != null ? Math.Min(RawTime.Value - HitObject.GetEndTime(), HitObject.MaximumJudgementOffset) : 0; internal set => RawTime = HitObject.GetEndTime() + value; } /// /// The absolute time at which this occurred, clamped by the end time of plus . /// /// /// The end time of is returned if this result is not populated yet. /// public double TimeAbsolute => RawTime != null ? Math.Min(RawTime.Value, HitObject.GetEndTime() + HitObject.MaximumJudgementOffset) : HitObject.GetEndTime(); /// /// The combo prior to this occurring. /// public int ComboAtJudgement { get; internal set; } /// /// The combo after this occurred. /// public int ComboAfterJudgement { get; internal set; } /// /// The highest combo achieved prior to this occurring. /// public int HighestComboAtJudgement { get; internal set; } /// /// The health prior to this occurring. /// public double HealthAtJudgement { get; internal set; } /// /// Whether the user was in a failed state prior to this occurring. /// public bool FailedAtJudgement { get; internal set; } /// /// Whether a miss or hit occurred. /// public bool HasResult => Type > HitResult.None; /// /// Whether a successful hit occurred. /// public bool IsHit => Type.IsHit(); /// /// Creates a new . /// /// The which was judged. /// The to refer to for scoring information. public JudgementResult([NotNull] HitObject hitObject, [NotNull] Judgement judgement) { HitObject = hitObject; Judgement = judgement; Reset(); } internal void Reset() { Type = HitResult.None; RawTime = null; } public override string ToString() => $"{Type} (Score:{Judgement.NumericResultFor(this)} HP:{Judgement.HealthIncreaseFor(this)} {Judgement})"; } }