2021-02-24 13:32:50 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System;
|
2021-08-12 10:12:35 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Game.Configuration;
|
2021-02-24 13:32:50 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mods
|
|
|
|
{
|
|
|
|
public abstract class ModFailCondition : Mod, IApplicableToHealthProcessor, IApplicableFailOverride
|
|
|
|
{
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
|
|
|
|
|
2021-08-12 10:12:35 +08:00
|
|
|
[SettingSource("Restart on fail", "Automatically restarts when failed.")]
|
|
|
|
public BindableBool Restart { get; } = new BindableBool();
|
|
|
|
|
2021-02-24 14:03:37 +08:00
|
|
|
public virtual bool PerformFail() => true;
|
2021-02-24 13:32:50 +08:00
|
|
|
|
2021-08-12 10:14:01 +08:00
|
|
|
public virtual bool RestartOnFail => Restart.Value;
|
2021-02-24 13:32:50 +08:00
|
|
|
|
|
|
|
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
|
|
|
{
|
|
|
|
healthProcessor.FailConditions += FailCondition;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract bool FailCondition(HealthProcessor healthProcessor, JudgementResult result);
|
|
|
|
}
|
|
|
|
}
|