1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 23:12:56 +08:00

Add auto-restart functionality to sudden death and perfect mods (#6159)

Add auto-restart functionality to sudden death and perfect mods

Co-authored-by: Paul Teng <plankp@outlook.com>
Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
Dean Herbert 2019-09-19 18:49:09 +09:00 committed by GitHub
commit 28342baa8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 1 deletions

View File

@ -25,6 +25,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) };
public bool AllowFail => false;
public bool RestartOnFail => false;
private OsuInputManager inputManager;

View File

@ -12,5 +12,10 @@ namespace osu.Game.Rulesets.Mods
/// Whether we should allow failing at the current point in time.
/// </summary>
bool AllowFail { get; }
/// <summary>
/// Whether we want to restart on fail. Only used if <see cref="AllowFail"/> is true.
/// </summary>
bool RestartOnFail { get; }
}
}

View File

@ -26,7 +26,10 @@ namespace osu.Game.Rulesets.Mods
public override ModType Type => ModType.Automation;
public override string Description => "Watch a perfect automated play through the song.";
public override double ScoreMultiplier => 1;
public bool AllowFail => false;
public bool RestartOnFail => false;
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) };
public override bool HasImplementation => GetType().GenericTypeArguments.Length == 0;

View File

@ -16,6 +16,8 @@ namespace osu.Game.Rulesets.Mods
/// </summary>
public bool AllowFail => false;
public bool RestartOnFail => false;
public void ReadFromConfig(OsuConfigManager config)
{
showHealthBar = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail);

View File

@ -10,7 +10,7 @@ using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModSuddenDeath : Mod, IApplicableToScoreProcessor
public abstract class ModSuddenDeath : Mod, IApplicableToScoreProcessor, IApplicableFailOverride
{
public override string Name => "Sudden Death";
public override string Acronym => "SD";
@ -21,6 +21,9 @@ namespace osu.Game.Rulesets.Mods
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
public bool AllowFail => true;
public bool RestartOnFail => true;
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
scoreProcessor.FailConditions += FailCondition;

View File

@ -378,6 +378,10 @@ namespace osu.Game.Screens.Play
PauseOverlay.Hide();
failAnimation.Start();
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
Restart();
return true;
}