mirror of
https://github.com/ppy/osu
synced 2025-01-31 10:22:02 +00:00
chore(osu.Game): provide ordering index for HitResult
This commit is contained in:
parent
5f0832ead7
commit
074d2a7a3a
@ -4,10 +4,12 @@
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Utils;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
@ -135,6 +137,8 @@ namespace osu.Game.Rulesets.Scoring
|
||||
#pragma warning disable CS0618
|
||||
public static class HitResultExtensions
|
||||
{
|
||||
private static readonly IList<HitResult> order = EnumExtensions.GetValuesInOrder<HitResult>().ToList();
|
||||
|
||||
/// <summary>
|
||||
/// Whether a <see cref="HitResult"/> increases the combo.
|
||||
/// </summary>
|
||||
@ -282,6 +286,16 @@ namespace osu.Game.Rulesets.Scoring
|
||||
Debug.Assert(minResult <= maxResult);
|
||||
return result > minResult && result < maxResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ordered index of a <see cref="HitResult"/>. Used for sorting.
|
||||
/// </summary>
|
||||
/// <param name="result">The <see cref="HitResult"/> to get the index of.</param>
|
||||
/// <returns>The index of <paramref name="result"/>.</returns>
|
||||
public static int OrderingIndex(this HitResult result)
|
||||
{
|
||||
return order.IndexOf(result);
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user