From b330aec03e54447b0788c2029d13d55b1db70e6d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 27 Dec 2019 16:14:49 +0900 Subject: [PATCH] Drain starting at the first hitobject, not gameplay start --- .../Scoring/TaikoHealthProcessor.cs | 4 ++-- osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 2 +- osu.Game/Rulesets/Ruleset.cs | 2 +- .../Scoring/AccumulatingHealthProcessor.cs | 4 +--- .../Rulesets/Scoring/DrainingHealthProcessor.cs | 15 +++++++++------ osu.Game/Rulesets/Scoring/HealthProcessor.cs | 14 -------------- osu.Game/Screens/Play/Player.cs | 2 +- 7 files changed, 15 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Scoring/TaikoHealthProcessor.cs b/osu.Game.Rulesets.Taiko/Scoring/TaikoHealthProcessor.cs index 279d119626..edb089dbac 100644 --- a/osu.Game.Rulesets.Taiko/Scoring/TaikoHealthProcessor.cs +++ b/osu.Game.Rulesets.Taiko/Scoring/TaikoHealthProcessor.cs @@ -30,8 +30,8 @@ namespace osu.Game.Rulesets.Taiko.Scoring /// private double hpMissMultiplier; - public TaikoHealthProcessor(double gameplayStartTime) - : base(gameplayStartTime, 0.5) + public TaikoHealthProcessor() + : base(0.5) { } diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 371236e47a..777b68a993 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Taiko public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(); - public override HealthProcessor CreateHealthProcessor(double gameplayStartTime) => new TaikoHealthProcessor(gameplayStartTime); + public override HealthProcessor CreateHealthProcessor(double drainStartTime) => new TaikoHealthProcessor(); public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this); diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index ff58d3c8dc..67ec6d15ea 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -80,7 +80,7 @@ namespace osu.Game.Rulesets /// Creates a for this . /// /// The health processor. - public virtual HealthProcessor CreateHealthProcessor(double gameplayStartTime) => new DrainingHealthProcessor(gameplayStartTime); + public virtual HealthProcessor CreateHealthProcessor(double drainStartTime) => new DrainingHealthProcessor(drainStartTime); /// /// Creates a to convert a to one that is applicable for this . diff --git a/osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs b/osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs index 540b4b8a1d..5dfb5167f4 100644 --- a/osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs @@ -16,10 +16,8 @@ namespace osu.Game.Rulesets.Scoring /// /// Creates a new . /// - /// The gameplay start time. /// The minimum amount of health required to beatmap. - public AccumulatingHealthProcessor(double gameplayStartTime, double requiredHealth) - : base(gameplayStartTime) + public AccumulatingHealthProcessor(double requiredHealth) { this.requiredHealth = requiredHealth; } diff --git a/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs b/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs index 34ede153dd..fffcbb3c9f 100644 --- a/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs @@ -38,8 +38,11 @@ namespace osu.Game.Rulesets.Scoring private const double max_health_target = 0.30; private IBeatmap beatmap; + private double gameplayEndTime; + private readonly double drainStartTime; + private readonly List<(double time, double health)> healthIncreases = new List<(double, double)>(); private double targetMinimumHealth; private double drainRate = 1; @@ -47,10 +50,10 @@ namespace osu.Game.Rulesets.Scoring /// /// Creates a new . /// - /// The gameplay start time. - public DrainingHealthProcessor(double gameplayStartTime) - : base(gameplayStartTime) + /// The time after which draining should begin. + public DrainingHealthProcessor(double drainStartTime) { + this.drainStartTime = drainStartTime; } protected override void Update() @@ -60,8 +63,8 @@ namespace osu.Game.Rulesets.Scoring if (!IsBreakTime.Value) { // When jumping in and out of gameplay time within a single frame, health should only be drained for the period within the gameplay time - double lastGameplayTime = Math.Clamp(Time.Current - Time.Elapsed, GameplayStartTime, gameplayEndTime); - double currentGameplayTime = Math.Clamp(Time.Current, GameplayStartTime, gameplayEndTime); + double lastGameplayTime = Math.Clamp(Time.Current - Time.Elapsed, drainStartTime, gameplayEndTime); + double currentGameplayTime = Math.Clamp(Time.Current, drainStartTime, gameplayEndTime); Health.Value -= drainRate * (currentGameplayTime - lastGameplayTime); } @@ -116,7 +119,7 @@ namespace osu.Game.Rulesets.Scoring for (int i = 0; i < healthIncreases.Count; i++) { double currentTime = healthIncreases[i].time; - double lastTime = i > 0 ? healthIncreases[i - 1].time : GameplayStartTime; + double lastTime = i > 0 ? healthIncreases[i - 1].time : drainStartTime; // Subtract any break time from the duration since the last object if (beatmap.Breaks.Count > 0) diff --git a/osu.Game/Rulesets/Scoring/HealthProcessor.cs b/osu.Game/Rulesets/Scoring/HealthProcessor.cs index d8addc2b4d..0c6b3f67b4 100644 --- a/osu.Game/Rulesets/Scoring/HealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/HealthProcessor.cs @@ -36,20 +36,6 @@ namespace osu.Game.Rulesets.Scoring /// public bool HasFailed { get; private set; } - /// - /// The gameplay start time. - /// - protected readonly double GameplayStartTime; - - /// - /// Creates a new . - /// - /// The gameplay start time. - protected HealthProcessor(double gameplayStartTime) - { - GameplayStartTime = gameplayStartTime; - } - protected override void ApplyResultInternal(JudgementResult result) { result.HealthAtJudgement = Health.Value; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a3d512cdaa..7228e22382 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -135,7 +135,7 @@ namespace osu.Game.Screens.Play ScoreProcessor.ApplyBeatmap(playableBeatmap); ScoreProcessor.Mods.BindTo(Mods); - HealthProcessor = ruleset.CreateHealthProcessor(DrawableRuleset.GameplayStartTime); + HealthProcessor = ruleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime); HealthProcessor.ApplyBeatmap(playableBeatmap); if (!ScoreProcessor.Mode.Disabled)