chore(osu.Game): provide ordering index for HitResult

This commit is contained in:
Acid Chicken (硫酸鶏) 2022-09-05 02:01:44 +09:00
parent 5f0832ead7
commit 074d2a7a3a
No known key found for this signature in database
GPG Key ID: 3E87B98A3F6BAB99

View File

@ -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
}