osu/osu.Game/Rulesets/Scoring/HitResult.cs

169 lines
4.5 KiB
C#
Raw Normal View History

// 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 09:19:50 +00:00
using System.ComponentModel;
2020-09-25 11:11:27 +00:00
using osu.Game.Utils;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Scoring
{
2020-09-25 11:11:27 +00:00
[HasOrderedElements]
2018-04-13 09:19:50 +00:00
public enum HitResult
{
/// <summary>
/// Indicates that the object has not been judged yet.
/// </summary>
[Description(@"")]
2020-09-25 11:11:27 +00:00
[Order(13)]
2018-04-13 09:19:50 +00:00
None,
2020-09-25 11:11:27 +00:00
[Order(12)]
Ignore,
2018-04-13 09:19:50 +00:00
/// <summary>
/// Indicates that the object has been judged as a miss.
/// </summary>
2019-09-06 06:24:00 +00:00
/// <remarks>
/// This miss window should determine how early a hit can be before it is considered for judgement (as opposed to being ignored as
/// "too far in the future). It should also define when a forced miss should be triggered (as a result of no user input in time).
/// </remarks>
2018-04-13 09:19:50 +00:00
[Description(@"Miss")]
2020-09-25 11:11:27 +00:00
[Order(5)]
2018-04-13 09:19:50 +00:00
Miss,
[Description(@"Meh")]
2020-09-25 11:11:27 +00:00
[Order(4)]
2018-04-13 09:19:50 +00:00
Meh,
/// <summary>
/// Optional judgement.
/// </summary>
[Description(@"OK")]
2020-09-25 11:11:27 +00:00
[Order(3)]
2018-04-13 09:19:50 +00:00
Ok,
[Description(@"Good")]
2020-09-25 11:11:27 +00:00
[Order(2)]
2018-04-13 09:19:50 +00:00
Good,
[Description(@"Great")]
2020-09-25 11:11:27 +00:00
[Order(1)]
2018-04-13 09:19:50 +00:00
Great,
/// <summary>
/// Optional judgement.
/// </summary>
[Description(@"Perfect")]
2020-09-25 11:11:27 +00:00
[Order(0)]
2018-04-13 09:19:50 +00:00
Perfect,
2020-05-04 06:55:42 +00:00
/// <summary>
/// Indicates small tick miss.
/// </summary>
2020-09-25 11:11:27 +00:00
[Order(11)]
SmallTickMiss,
2020-05-04 06:55:42 +00:00
/// <summary>
/// Indicates a small tick hit.
/// </summary>
2020-09-25 11:11:27 +00:00
[Description(@"S Tick")]
[Order(7)]
2020-05-04 06:55:42 +00:00
SmallTickHit,
/// <summary>
/// Indicates a large tick miss.
/// </summary>
2020-09-25 11:11:27 +00:00
[Order(10)]
LargeTickMiss,
2020-05-04 06:55:42 +00:00
/// <summary>
/// Indicates a large tick hit.
/// </summary>
2020-09-25 11:11:27 +00:00
[Description(@"L Tick")]
[Order(6)]
LargeTickHit,
/// <summary>
/// Indicates a small bonus.
/// </summary>
[Description("S Bonus")]
[Order(9)]
SmallBonus,
/// <summary>
/// Indicate a large bonus.
/// </summary>
[Description("L Bonus")]
[Order(8)]
LargeBonus,
}
public static class HitResultExtensions
{
/// <summary>
/// Whether a <see cref="HitResult"/> affects the combo.
/// </summary>
public static bool AffectsCombo(this HitResult result)
{
switch (result)
{
case HitResult.Miss:
case HitResult.Meh:
case HitResult.Ok:
case HitResult.Good:
case HitResult.Great:
case HitResult.Perfect:
case HitResult.LargeTickHit:
case HitResult.LargeTickMiss:
return true;
default:
return false;
}
}
/// <summary>
/// Whether a <see cref="HitResult"/> should be counted as combo score.
/// </summary>
/// <remarks>
/// This is not the reciprocal of <see cref="AffectsCombo"/>, as <see cref="HitResult.SmallTickHit"/> and <see cref="HitResult.SmallTickMiss"/> do not affect combo
/// but are still considered as part of the accuracy (not bonus) portion of the score.
/// </remarks>
public static bool IsBonus(this HitResult result)
{
switch (result)
{
case HitResult.SmallBonus:
case HitResult.LargeBonus:
return true;
default:
return false;
}
}
/// <summary>
/// Whether a <see cref="HitResult"/> represents a successful hit.
/// </summary>
public static bool IsHit(this HitResult result)
{
switch (result)
{
case HitResult.None:
case HitResult.Ignore:
case HitResult.Miss:
case HitResult.SmallTickMiss:
case HitResult.LargeTickMiss:
return false;
default:
return true;
}
}
/// <summary>
/// Whether a <see cref="HitResult"/> is scorable.
/// </summary>
public static bool IsScorable(this HitResult result) => result > HitResult.Ignore;
2018-04-13 09:19:50 +00:00
}
}