1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-24 13:22:55 +08:00

Store FailTrigger in HealthProcessor

This commit is contained in:
Peter-io 2024-07-11 17:49:43 +02:00
parent 307a0e8bfa
commit 2aeda54865

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Bindables;
using osu.Framework.Utils;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Scoring
{
@ -31,16 +32,24 @@ namespace osu.Game.Rulesets.Scoring
/// </summary>
public bool HasFailed { get; private set; }
/// <summary>
/// Object that triggered fail
/// </summary>
public object? FailTrigger;
/// <summary>
/// Immediately triggers a failure for this HealthProcessor.
/// </summary>
public void TriggerFailure()
public void TriggerFailure(object? Trigger = null)
{
if (HasFailed)
return;
if (Failed?.Invoke() != false)
HasFailed = true;
if (Trigger != null)
FailTrigger = Trigger;
}
protected override void ApplyResultInternal(JudgementResult result)
@ -92,7 +101,10 @@ namespace osu.Game.Rulesets.Scoring
{
bool conditionResult = (bool)condition.Method.Invoke(condition.Target, new object[] { this, result })!;
if (conditionResult)
{
FailTrigger = condition.Target;
return true;
}
}
}