mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
use event to trigger failure
This commit is contained in:
parent
21c5499da1
commit
6e64a8f55e
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user