mirror of https://github.com/ppy/osu
Implement NoFail mod
This commit is contained in:
parent
3416925233
commit
224de9cc1e
|
@ -45,5 +45,10 @@ public abstract class Mod
|
||||||
/// The mods this mod cannot be enabled with.
|
/// The mods this mod cannot be enabled with.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Type[] IncompatibleMods => new Type[] { };
|
public virtual Type[] IncompatibleMods => new Type[] { };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we should allow fails at the
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool AllowFail => true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,5 +15,10 @@ public abstract class ModNoFail : Mod
|
||||||
public override double ScoreMultiplier => 0.5;
|
public override double ScoreMultiplier => 0.5;
|
||||||
public override bool Ranked => true;
|
public override bool Ranked => true;
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModAutoplay) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModAutoplay) };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// We never fail, 'yo.
|
||||||
|
/// </summary>
|
||||||
|
public override bool AllowFail => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,8 +16,9 @@ public abstract class ScoreProcessor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when the ScoreProcessor is in a failed state.
|
/// Invoked when the ScoreProcessor is in a failed state.
|
||||||
|
/// Return true if the fail was permitted.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action Failed;
|
public event Func<bool> Failed;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a new judgement has occurred. This occurs after the judgement has been processed by the <see cref="ScoreProcessor"/>.
|
/// Invoked when a new judgement has occurred. This occurs after the judgement has been processed by the <see cref="ScoreProcessor"/>.
|
||||||
|
@ -106,8 +107,8 @@ protected void UpdateFailed()
|
||||||
if (alreadyFailed || !HasFailed)
|
if (alreadyFailed || !HasFailed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
alreadyFailed = true;
|
if (Failed?.Invoke() != false)
|
||||||
Failed?.Invoke();
|
alreadyFailed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -238,13 +238,17 @@ private void onCompletion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFail()
|
private bool onFail()
|
||||||
{
|
{
|
||||||
|
if (Beatmap.Value.Mods.Value.Any(m => !m.AllowFail))
|
||||||
|
return false;
|
||||||
|
|
||||||
decoupledClock.Stop();
|
decoupledClock.Stop();
|
||||||
|
|
||||||
HasFailed = true;
|
HasFailed = true;
|
||||||
failOverlay.Retries = RestartCount;
|
failOverlay.Retries = RestartCount;
|
||||||
failOverlay.Show();
|
failOverlay.Show();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnEntering(Screen last)
|
protected override void OnEntering(Screen last)
|
||||||
|
|
Loading…
Reference in New Issue