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