1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 13:47:33 +08:00

use event to trigger failure

This commit is contained in:
Gabe Livengood 2022-06-10 13:13:35 -04:00
parent 21c5499da1
commit 6e64a8f55e
No known key found for this signature in database
GPG Key ID: 70321B78DAECE683

View File

@ -19,18 +19,18 @@ namespace osu.Game.Rulesets.Mods
public virtual bool PerformFail() => true;
public virtual bool RestartOnFail => Restart.Value;
private HealthProcessor healthProcessorInternal;
private event Action failureTriggered;
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{
healthProcessorInternal = healthProcessor;
failureTriggered = healthProcessor.TriggerFailure;
healthProcessor.FailConditions += FailCondition;
}
/// <summary>
/// Immediately triggers a failure on the loaded <see cref="HealthProcessor"/>.
/// </summary>
protected void TriggerFailure() => healthProcessorInternal.TriggerFailure();
protected void TriggerFailure() => failureTriggered?.Invoke();
/// <summary>
/// Determines whether <paramref name="result"/> should trigger a failure. Called every time a