From f6e1cb07a1b9d3418105e2c8399caba3bd9fe1ee Mon Sep 17 00:00:00 2001 From: RORIdev Date: Wed, 3 Apr 2019 17:58:17 -0300 Subject: [PATCH] Changed the logic to ModEasy. --- osu.Game/Rulesets/Mods/ModEasy.cs | 20 +++++++++++++++++++- osu.Game/Screens/Play/Player.cs | 29 ++++++----------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/osu.Game/Rulesets/Mods/ModEasy.cs b/osu.Game/Rulesets/Mods/ModEasy.cs index 56ec0bec06..ec18496966 100644 --- a/osu.Game/Rulesets/Mods/ModEasy.cs +++ b/osu.Game/Rulesets/Mods/ModEasy.cs @@ -5,11 +5,13 @@ using System; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Mods { - public abstract class ModEasy : Mod, IApplicableToDifficulty + public abstract class ModEasy : Mod, IApplicableToDifficulty, IApplicableToScoreProcessor { + public static int Lives = 2; public override string Name => "Easy"; public override string Acronym => "EZ"; public override IconUsage Icon => OsuIcon.ModEasy; @@ -26,5 +28,21 @@ namespace osu.Game.Rulesets.Mods difficulty.DrainRate *= ratio; difficulty.OverallDifficulty *= ratio; } + + public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor) + { + scoreProcessor.Health.ValueChanged += ValueChanged =>{ + if (scoreProcessor.Health.Value == 0) + { + if (Lives != 0) + { + Lives--; + scoreProcessor.Health.Value = 100; + } + } + + } ; + + } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 800adcd928..864cbc8878 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -325,38 +325,21 @@ namespace osu.Game.Screens.Play protected FailOverlay FailOverlay { get; private set; } - private void fail() - { - GameplayClockContainer.Stop(); - HasFailed = true; - FailOverlay.Retries = RestartCount; - FailOverlay.Show(); - } + private bool onFail() { - //issue #3372 - if (Beatmap.Value.Mods.Value.Any(x => x is ModEasy)) - { - if (Lives != 0) - { - Lives--; - ScoreProcessor.Health.Value = 100; - return false; - } - else - { - fail(); - return true; - } - } + if (Beatmap.Value.Mods.Value.OfType().Any(m => !m.AllowFail)) return false; + GameplayClockContainer.Stop(); + HasFailed = true; // There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer) // could process an extra frame after the GameplayClock is stopped. // In such cases we want the fail state to precede a user triggered pause. if (PauseOverlay.State == Visibility.Visible) PauseOverlay.Hide(); - fail(); + FailOverlay.Retries = RestartCount; + FailOverlay.Show(); return true; }