1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Fix fail check ordering not being enforced correctly

This commit is contained in:
Dean Herbert 2024-08-06 23:10:26 +09:00
parent 9ed8528a40
commit 278e227115
No known key found for this signature in database
2 changed files with 16 additions and 3 deletions

View File

@ -25,6 +25,11 @@ namespace osu.Game.Rulesets.Scoring
/// </summary> /// </summary>
public readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>()); public readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
/// <summary>
/// Mods which can override fail ordered in the correct order for checks.
/// </summary>
public IApplicableFailOverride[] OrderedFailOverrideMods { get; private set; } = Array.Empty<IApplicableFailOverride>();
/// <summary> /// <summary>
/// The current health. /// The current health.
/// </summary> /// </summary>
@ -59,6 +64,14 @@ namespace osu.Game.Rulesets.Scoring
ModTriggeringFailure = triggeringMod; ModTriggeringFailure = triggeringMod;
} }
protected HealthProcessor()
{
Mods.BindValueChanged(mods =>
{
OrderedFailOverrideMods = mods.NewValue.OfType<IApplicableFailOverride>().OrderByDescending(m => m.RestartOnFail).ToArray();
});
}
protected override void ApplyResultInternal(JudgementResult result) protected override void ApplyResultInternal(JudgementResult result)
{ {
result.HealthAtJudgement = Health.Value; result.HealthAtJudgement = Health.Value;
@ -102,7 +115,7 @@ namespace osu.Game.Rulesets.Scoring
if (CheckDefaultFailCondition(result)) if (CheckDefaultFailCondition(result))
return true; return true;
foreach (var condition in Mods.Value.OfType<IApplicableFailOverride>()) foreach (var condition in OrderedFailOverrideMods)
{ {
if (condition.CheckFail(result) == FailState.Force) if (condition.CheckFail(result) == FailState.Force)
{ {

View File

@ -152,7 +152,7 @@ namespace osu.Game.Screens.Play
/// Whether failing should be allowed. /// Whether failing should be allowed.
/// By default, this checks whether all selected mods allow failing. /// By default, this checks whether all selected mods allow failing.
/// </summary> /// </summary>
protected virtual bool CheckModsAllowFailure() => HealthProcessor.Mods.Value.OfType<IApplicableFailOverride>().All(m => m.CheckFail(null) != FailState.Block); protected virtual bool CheckModsAllowFailure() => HealthProcessor.OrderedFailOverrideMods.All(m => m.CheckFail(null) != FailState.Block);
public readonly PlayerConfiguration Configuration; public readonly PlayerConfiguration Configuration;
@ -244,7 +244,7 @@ namespace osu.Game.Screens.Play
HealthProcessor = gameplayMods.OfType<IApplicableHealthProcessor>().FirstOrDefault()?.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime); HealthProcessor = gameplayMods.OfType<IApplicableHealthProcessor>().FirstOrDefault()?.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime);
HealthProcessor ??= ruleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime); HealthProcessor ??= ruleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime);
HealthProcessor.Mods.Value = gameplayMods.OrderByDescending(m => m is IApplicableFailOverride mod && mod.RestartOnFail).ToArray(); HealthProcessor.Mods.Value = gameplayMods;
HealthProcessor.ApplyBeatmap(playableBeatmap); HealthProcessor.ApplyBeatmap(playableBeatmap);
dependencies.CacheAs(HealthProcessor); dependencies.CacheAs(HealthProcessor);