mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Add adjustable target percentage
This commit is contained in:
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
@ -34,8 +35,15 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
public bool HasFailed { get; private set; }
|
public bool HasFailed { get; private set; }
|
||||||
|
|
||||||
private readonly List<(double time, double health)> healthIncreases = new List<(double time, double health)>();
|
private readonly List<(double time, double health)> healthIncreases = new List<(double time, double health)>();
|
||||||
|
private double targetMinimumHealth;
|
||||||
private double drainRate = 1;
|
private double drainRate = 1;
|
||||||
|
|
||||||
|
public override void ApplyBeatmap(IBeatmap beatmap)
|
||||||
|
{
|
||||||
|
targetMinimumHealth = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.95, 0.85, 0.65);
|
||||||
|
base.ApplyBeatmap(beatmap);
|
||||||
|
}
|
||||||
|
|
||||||
public override void ApplyElapsedTime(double elapsedTime) => Health.Value -= drainRate * elapsedTime;
|
public override void ApplyElapsedTime(double elapsedTime) => Health.Value -= drainRate * elapsedTime;
|
||||||
|
|
||||||
protected override void ApplyResultInternal(JudgementResult result)
|
protected override void ApplyResultInternal(JudgementResult result)
|
||||||
@ -85,8 +93,6 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
|
|
||||||
if (storeResults)
|
if (storeResults)
|
||||||
{
|
{
|
||||||
const double percentage_target = 0.5;
|
|
||||||
|
|
||||||
int count = 1;
|
int count = 1;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@ -107,11 +113,11 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.Abs(lowestHealth - percentage_target) <= 0.01)
|
if (Math.Abs(lowestHealth - targetMinimumHealth) <= 0.01)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
count *= 2;
|
count *= 2;
|
||||||
drainRate += 1.0 / count * Math.Sign(lowestHealth - percentage_target);
|
drainRate += 1.0 / count * Math.Sign(lowestHealth - targetMinimumHealth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// Applies a <see cref="IBeatmap"/> to this <see cref="ScoreProcessor"/>.
|
/// Applies a <see cref="IBeatmap"/> to this <see cref="ScoreProcessor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The <see cref="IBeatmap"/> to read properties from.</param>
|
/// <param name="beatmap">The <see cref="IBeatmap"/> to read properties from.</param>
|
||||||
public void ApplyBeatmap(IBeatmap beatmap)
|
public virtual void ApplyBeatmap(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
Reset(false);
|
Reset(false);
|
||||||
SimulateAutoplay(beatmap);
|
SimulateAutoplay(beatmap);
|
||||||
|
Reference in New Issue
Block a user