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