diff --git a/osu.Game/Rulesets/Scoring/HealthProcessor.cs b/osu.Game/Rulesets/Scoring/HealthProcessor.cs index 26320de057..28d0d64841 100644 --- a/osu.Game/Rulesets/Scoring/HealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/HealthProcessor.cs @@ -2,9 +2,12 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; +using System.Linq; using osu.Framework.Bindables; using osu.Framework.Utils; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Scoring { @@ -19,7 +22,7 @@ namespace osu.Game.Rulesets.Scoring /// /// Additional conditions on top of that cause a failing state. /// - public event Func? FailConditions; + public List FailConditions = new List(); /// /// The current health. @@ -34,12 +37,12 @@ namespace osu.Game.Rulesets.Scoring /// /// Object that triggered fail /// - public object? FailTrigger; + public List FailTriggers = new List(); /// /// Immediately triggers a failure for this HealthProcessor. /// - public void TriggerFailure(object? Trigger = null) + public void TriggerFailure(IHasFailCondition? Trigger = null) { if (HasFailed) return; @@ -48,7 +51,7 @@ namespace osu.Game.Rulesets.Scoring HasFailed = true; if (Trigger != null) - FailTrigger = Trigger; + FailTriggers.Add(Trigger); } protected override void ApplyResultInternal(JudgementResult result) @@ -94,17 +97,16 @@ namespace osu.Game.Rulesets.Scoring if (CheckDefaultFailCondition(result)) return true; - if (FailConditions != null) + if (FailConditions.Any()) { - foreach (var condition in FailConditions.GetInvocationList()) + foreach (var condition in FailConditions) { - bool conditionResult = (bool)condition.Method.Invoke(condition.Target, new object[] { this, result })!; - if (conditionResult) - { - FailTrigger = condition.Target; - return true; - } + if (condition.FailCondition(result)) + FailTriggers.Add(condition); } + + if (FailTriggers.Any()) + return true; } return false;