Drain starting at the first hitobject, not gameplay start

This commit is contained in:
Dean Herbert 2019-12-27 16:14:49 +09:00
parent aa97487f8e
commit b330aec03e
7 changed files with 15 additions and 28 deletions

View File

@ -30,8 +30,8 @@ namespace osu.Game.Rulesets.Taiko.Scoring
/// </summary> /// </summary>
private double hpMissMultiplier; private double hpMissMultiplier;
public TaikoHealthProcessor(double gameplayStartTime) public TaikoHealthProcessor()
: base(gameplayStartTime, 0.5) : base(0.5)
{ {
} }

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Taiko
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(); 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); public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this);

View File

@ -80,7 +80,7 @@ namespace osu.Game.Rulesets
/// Creates a <see cref="HealthProcessor"/> for this <see cref="Ruleset"/>. /// Creates a <see cref="HealthProcessor"/> for this <see cref="Ruleset"/>.
/// </summary> /// </summary>
/// <returns>The health processor.</returns> /// <returns>The health processor.</returns>
public virtual HealthProcessor CreateHealthProcessor(double gameplayStartTime) => new DrainingHealthProcessor(gameplayStartTime); public virtual HealthProcessor CreateHealthProcessor(double drainStartTime) => new DrainingHealthProcessor(drainStartTime);
/// <summary> /// <summary>
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>. /// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.

View File

@ -16,10 +16,8 @@ namespace osu.Game.Rulesets.Scoring
/// <summary> /// <summary>
/// Creates a new <see cref="AccumulatingHealthProcessor"/>. /// Creates a new <see cref="AccumulatingHealthProcessor"/>.
/// </summary> /// </summary>
/// <param name="gameplayStartTime">The gameplay start time.</param>
/// <param name="requiredHealth">The minimum amount of health required to beatmap.</param> /// <param name="requiredHealth">The minimum amount of health required to beatmap.</param>
public AccumulatingHealthProcessor(double gameplayStartTime, double requiredHealth) public AccumulatingHealthProcessor(double requiredHealth)
: base(gameplayStartTime)
{ {
this.requiredHealth = requiredHealth; this.requiredHealth = requiredHealth;
} }

View File

@ -38,8 +38,11 @@ namespace osu.Game.Rulesets.Scoring
private const double max_health_target = 0.30; private const double max_health_target = 0.30;
private IBeatmap beatmap; private IBeatmap beatmap;
private double gameplayEndTime; private double gameplayEndTime;
private readonly double drainStartTime;
private readonly List<(double time, double health)> healthIncreases = new List<(double, double)>(); private readonly List<(double time, double health)> healthIncreases = new List<(double, double)>();
private double targetMinimumHealth; private double targetMinimumHealth;
private double drainRate = 1; private double drainRate = 1;
@ -47,10 +50,10 @@ namespace osu.Game.Rulesets.Scoring
/// <summary> /// <summary>
/// Creates a new <see cref="DrainingHealthProcessor"/>. /// Creates a new <see cref="DrainingHealthProcessor"/>.
/// </summary> /// </summary>
/// <param name="gameplayStartTime">The gameplay start time.</param> /// <param name="drainStartTime">The time after which draining should begin.</param>
public DrainingHealthProcessor(double gameplayStartTime) public DrainingHealthProcessor(double drainStartTime)
: base(gameplayStartTime)
{ {
this.drainStartTime = drainStartTime;
} }
protected override void Update() protected override void Update()
@ -60,8 +63,8 @@ namespace osu.Game.Rulesets.Scoring
if (!IsBreakTime.Value) 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 // 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 lastGameplayTime = Math.Clamp(Time.Current - Time.Elapsed, drainStartTime, gameplayEndTime);
double currentGameplayTime = Math.Clamp(Time.Current, GameplayStartTime, gameplayEndTime); double currentGameplayTime = Math.Clamp(Time.Current, drainStartTime, gameplayEndTime);
Health.Value -= drainRate * (currentGameplayTime - lastGameplayTime); Health.Value -= drainRate * (currentGameplayTime - lastGameplayTime);
} }
@ -116,7 +119,7 @@ namespace osu.Game.Rulesets.Scoring
for (int i = 0; i < healthIncreases.Count; i++) for (int i = 0; i < healthIncreases.Count; i++)
{ {
double currentTime = healthIncreases[i].time; 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 // Subtract any break time from the duration since the last object
if (beatmap.Breaks.Count > 0) if (beatmap.Breaks.Count > 0)

View File

@ -36,20 +36,6 @@ namespace osu.Game.Rulesets.Scoring
/// </summary> /// </summary>
public bool HasFailed { get; private set; } public bool HasFailed { get; private set; }
/// <summary>
/// The gameplay start time.
/// </summary>
protected readonly double GameplayStartTime;
/// <summary>
/// Creates a new <see cref="HealthProcessor"/>.
/// </summary>
/// <param name="gameplayStartTime">The gameplay start time.</param>
protected HealthProcessor(double gameplayStartTime)
{
GameplayStartTime = gameplayStartTime;
}
protected override void ApplyResultInternal(JudgementResult result) protected override void ApplyResultInternal(JudgementResult result)
{ {
result.HealthAtJudgement = Health.Value; result.HealthAtJudgement = Health.Value;

View File

@ -135,7 +135,7 @@ namespace osu.Game.Screens.Play
ScoreProcessor.ApplyBeatmap(playableBeatmap); ScoreProcessor.ApplyBeatmap(playableBeatmap);
ScoreProcessor.Mods.BindTo(Mods); ScoreProcessor.Mods.BindTo(Mods);
HealthProcessor = ruleset.CreateHealthProcessor(DrawableRuleset.GameplayStartTime); HealthProcessor = ruleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime);
HealthProcessor.ApplyBeatmap(playableBeatmap); HealthProcessor.ApplyBeatmap(playableBeatmap);
if (!ScoreProcessor.Mode.Disabled) if (!ScoreProcessor.Mode.Disabled)