mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Fix HealthProcessor
fail conditions not handling multiple invocations
This commit is contained in:
parent
a884f20c65
commit
31f64b1381
@ -43,11 +43,11 @@ namespace osu.Game.Rulesets.Scoring
|
||||
|
||||
Health.Value += GetHealthIncreaseFor(result);
|
||||
|
||||
if (!DefaultFailCondition && FailConditions?.Invoke(this, result) != true)
|
||||
return;
|
||||
|
||||
if (Failed?.Invoke() != false)
|
||||
HasFailed = true;
|
||||
if (meetsFailConditions(result))
|
||||
{
|
||||
if (Failed?.Invoke() != false)
|
||||
HasFailed = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RevertResultInternal(JudgementResult result)
|
||||
@ -69,6 +69,28 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// </summary>
|
||||
protected virtual bool DefaultFailCondition => Precision.AlmostBigger(Health.MinValue, Health.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the current state of <see cref="HealthProcessor"/> or the provided <paramref name="result"/> meets the fail conditions.
|
||||
/// </summary>
|
||||
/// <param name="result">The judgement result.</param>
|
||||
private bool meetsFailConditions(JudgementResult result)
|
||||
{
|
||||
if (DefaultFailCondition)
|
||||
return true;
|
||||
|
||||
if (FailConditions != null)
|
||||
{
|
||||
foreach (var condition in FailConditions.GetInvocationList())
|
||||
{
|
||||
bool conditionResult = (bool)condition.Method.Invoke(condition.Target, new object[] { this, result });
|
||||
if (conditionResult)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Reset(bool storeResults)
|
||||
{
|
||||
base.Reset(storeResults);
|
||||
|
Loading…
Reference in New Issue
Block a user