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

Include TriggeredFail in mods

This commit is contained in:
Peter-io 2024-07-11 14:27:56 +02:00
parent 674d6eecd3
commit 8da673ec24
6 changed files with 22 additions and 4 deletions

View File

@ -103,11 +103,13 @@ namespace osu.Game.Rulesets.Osu.Mods
public bool RestartOnFail => false; public bool RestartOnFail => false;
public bool TriggeredFail { get; set; } = false;
public void ApplyToHealthProcessor(HealthProcessor healthProcessor) public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{ {
// Sudden death // Sudden death
healthProcessor.FailConditions += (_, result) healthProcessor.FailConditions += (_, result)
=> result.Type.AffectsCombo() => TriggeredFail = result.Type.AffectsCombo()
&& !result.IsHit; && !result.IsHit;
} }

View File

@ -51,5 +51,7 @@ namespace osu.Game.Rulesets.Mods
public bool PerformFail() => false; public bool PerformFail() => false;
public bool RestartOnFail => false; public bool RestartOnFail => false;
public bool TriggeredFail => false;
} }
} }

View File

@ -35,7 +35,11 @@ namespace osu.Game.Rulesets.Mods
public bool PerformFail() public bool PerformFail()
{ {
if (retries == 0) return true; if (retries == 0)
{
TriggeredFail = true;
return true;
}
health.Value = health.MaxValue; health.Value = health.MaxValue;
retries--; retries--;
@ -45,6 +49,8 @@ namespace osu.Game.Rulesets.Mods
public bool RestartOnFail => false; public bool RestartOnFail => false;
public bool TriggeredFail { get; set; } = false;
public void ApplyToHealthProcessor(HealthProcessor healthProcessor) public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{ {
health.BindTo(healthProcessor.Health); health.BindTo(healthProcessor.Health);

View File

@ -20,6 +20,8 @@ namespace osu.Game.Rulesets.Mods
public virtual bool RestartOnFail => Restart.Value; public virtual bool RestartOnFail => Restart.Value;
public virtual bool TriggeredFail { get; set; } = false;
private Action? triggerFailureDelegate; private Action? triggerFailureDelegate;
public void ApplyToHealthProcessor(HealthProcessor healthProcessor) public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
@ -31,7 +33,11 @@ namespace osu.Game.Rulesets.Mods
/// <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() => triggerFailureDelegate?.Invoke(); protected void TriggerFailure()
{
TriggeredFail = true;
triggerFailureDelegate?.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

View File

@ -31,6 +31,8 @@ namespace osu.Game.Rulesets.Mods
public bool RestartOnFail => false; public bool RestartOnFail => false;
public bool TriggeredFail => false;
public void ReadFromConfig(OsuConfigManager config) public void ReadFromConfig(OsuConfigManager config)
{ {
config.BindWith(OsuSetting.ShowHealthDisplayWhenCantFail, showHealthBar); config.BindWith(OsuSetting.ShowHealthDisplayWhenCantFail, showHealthBar);

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Mods
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModPerfect)).ToArray(); public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModPerfect)).ToArray();
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result) protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result)
=> result.Type.AffectsCombo() => TriggeredFail = result.Type.AffectsCombo()
&& !result.IsHit; && !result.IsHit;
} }
} }