mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +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);
|
Health.Value += GetHealthIncreaseFor(result);
|
||||||
|
|
||||||
if (!DefaultFailCondition && FailConditions?.Invoke(this, result) != true)
|
if (meetsFailConditions(result))
|
||||||
return;
|
{
|
||||||
|
if (Failed?.Invoke() != false)
|
||||||
if (Failed?.Invoke() != false)
|
HasFailed = true;
|
||||||
HasFailed = true;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RevertResultInternal(JudgementResult result)
|
protected override void RevertResultInternal(JudgementResult result)
|
||||||
@ -69,6 +69,28 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool DefaultFailCondition => Precision.AlmostBigger(Health.MinValue, Health.Value);
|
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)
|
protected override void Reset(bool storeResults)
|
||||||
{
|
{
|
||||||
base.Reset(storeResults);
|
base.Reset(storeResults);
|
||||||
|
Loading…
Reference in New Issue
Block a user