mirror of
https://github.com/ppy/osu.git
synced 2025-02-24 19:02:59 +08:00
Implement IHasFailCondition in mods
This commit is contained in:
parent
4a473f4011
commit
751006c08b
@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
|||||||
{
|
{
|
||||||
public class ManiaModPerfect : ModPerfect
|
public class ManiaModPerfect : ModPerfect
|
||||||
{
|
{
|
||||||
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result)
|
public override bool FailCondition(JudgementResult result)
|
||||||
{
|
{
|
||||||
if (!isRelevantResult(result.Judgement.MinResult) && !isRelevantResult(result.Judgement.MaxResult) && !isRelevantResult(result.Type))
|
if (!isRelevantResult(result.Judgement.MinResult) && !isRelevantResult(result.Judgement.MaxResult) && !isRelevantResult(result.Type))
|
||||||
return false;
|
return false;
|
||||||
|
@ -16,6 +16,7 @@ using osu.Game.Beatmaps.Timing;
|
|||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
@ -32,7 +33,7 @@ using osuTK.Graphics;
|
|||||||
namespace osu.Game.Rulesets.Osu.Mods
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
{
|
{
|
||||||
public class OsuModTargetPractice : ModWithVisibilityAdjustment, IApplicableToDrawableRuleset<OsuHitObject>,
|
public class OsuModTargetPractice : ModWithVisibilityAdjustment, IApplicableToDrawableRuleset<OsuHitObject>,
|
||||||
IApplicableToHealthProcessor, IApplicableToDifficulty, IApplicableFailOverride, IHasSeed, IHidesApproachCircles
|
IApplicableToHealthProcessor, IApplicableToDifficulty, IApplicableFailOverride, IHasSeed, IHidesApproachCircles, IHasFailCondition
|
||||||
{
|
{
|
||||||
public override string Name => "Target Practice";
|
public override string Name => "Target Practice";
|
||||||
public override string Acronym => "TP";
|
public override string Acronym => "TP";
|
||||||
@ -103,12 +104,14 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
public bool RestartOnFail => false;
|
public bool RestartOnFail => false;
|
||||||
|
|
||||||
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
// Sudden death
|
||||||
{
|
public bool FailCondition(JudgementResult result)
|
||||||
// Sudden death
|
|
||||||
healthProcessor.FailConditions += (_, result)
|
|
||||||
=> result.Type.AffectsCombo()
|
=> result.Type.AffectsCombo()
|
||||||
&& !result.IsHit;
|
&& !result.IsHit;
|
||||||
|
|
||||||
|
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
||||||
|
{
|
||||||
|
healthProcessor.FailConditions.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
||||||
|
|
||||||
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result) => false;
|
public override bool FailCondition(JudgementResult result) => false;
|
||||||
|
|
||||||
public enum AccuracyMode
|
public enum AccuracyMode
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModFailCondition : Mod, IApplicableToHealthProcessor, IApplicableFailOverride
|
public abstract class ModFailCondition : Mod, IApplicableToHealthProcessor, IApplicableFailOverride, IHasFailCondition
|
||||||
{
|
{
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModCinema) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModCinema) };
|
||||||
|
|
||||||
@ -20,12 +20,12 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public virtual bool RestartOnFail => Restart.Value;
|
public virtual bool RestartOnFail => Restart.Value;
|
||||||
|
|
||||||
private Action<object>? triggerFailureDelegate;
|
private Action<IHasFailCondition>? triggerFailureDelegate;
|
||||||
|
|
||||||
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
||||||
{
|
{
|
||||||
triggerFailureDelegate = healthProcessor.TriggerFailure;
|
triggerFailureDelegate = healthProcessor.TriggerFailure;
|
||||||
healthProcessor.FailConditions += FailCondition;
|
healthProcessor.FailConditions.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -45,6 +45,6 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// Using outside values to evaluate failure may introduce event ordering discrepancies, use
|
/// Using outside values to evaluate failure may introduce event ordering discrepancies, use
|
||||||
/// an <see cref="IApplicableMod"/> with <see cref="TriggerFailure"/> instead.
|
/// an <see cref="IApplicableMod"/> with <see cref="TriggerFailure"/> instead.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected abstract bool FailCondition(HealthProcessor healthProcessor, JudgementResult result);
|
public abstract bool FailCondition(JudgementResult result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
Restart.Value = Restart.Default = true;
|
Restart.Value = Restart.Default = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result)
|
public override bool FailCondition(JudgementResult result)
|
||||||
=> (isRelevantResult(result.Judgement.MinResult) || isRelevantResult(result.Judgement.MaxResult) || isRelevantResult(result.Type))
|
=> (isRelevantResult(result.Judgement.MinResult) || isRelevantResult(result.Judgement.MaxResult) || isRelevantResult(result.Type))
|
||||||
&& result.Type != result.Judgement.MaxResult;
|
&& result.Type != result.Judgement.MaxResult;
|
||||||
|
|
||||||
|
@ -23,7 +23,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)
|
public override bool FailCondition(JudgementResult result)
|
||||||
=> result.Type.AffectsCombo()
|
=> result.Type.AffectsCombo()
|
||||||
&& !result.IsHit;
|
&& !result.IsHit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user