mirror of https://github.com/ppy/osu
Extract duplicated conditionals
This commit is contained in:
parent
55737226a3
commit
ff7f65de27
|
@ -12,6 +12,7 @@
|
|||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
@ -124,10 +125,7 @@ public void ApplyToDrawableHitObject(DrawableHitObject drawable)
|
|||
drawable.OnNewResult += (o, result) =>
|
||||
{
|
||||
if (dequeuedRates.ContainsKey(result.HitObject)) return;
|
||||
|
||||
if (!result.IsHit) return;
|
||||
if (!result.Type.AffectsAccuracy()) return;
|
||||
if (!previousEndTimes.ContainsKey(result.HitObject)) return;
|
||||
if (!shouldProcessResult(result)) return;
|
||||
|
||||
double prevEndTime = previousEndTimes[result.HitObject];
|
||||
|
||||
|
@ -141,10 +139,7 @@ public void ApplyToDrawableHitObject(DrawableHitObject drawable)
|
|||
drawable.OnRevertResult += (o, result) =>
|
||||
{
|
||||
if (!dequeuedRates.ContainsKey(result.HitObject)) return;
|
||||
|
||||
if (!result.IsHit) return;
|
||||
if (!result.Type.AffectsAccuracy()) return;
|
||||
if (!previousEndTimes.ContainsKey(result.HitObject)) return;
|
||||
if (!shouldProcessResult(result)) return;
|
||||
|
||||
recentRates.Insert(0, dequeuedRates[result.HitObject]);
|
||||
recentRates.RemoveAt(recentRates.Count - 1);
|
||||
|
@ -179,5 +174,14 @@ private IEnumerable<HitObject> getAllApplicableHitObjects(IEnumerable<HitObject>
|
|||
yield return nested;
|
||||
}
|
||||
}
|
||||
|
||||
private bool shouldProcessResult(JudgementResult result)
|
||||
{
|
||||
if (!result.IsHit) return false;
|
||||
if (!result.Type.AffectsAccuracy()) return false;
|
||||
if (!previousEndTimes.ContainsKey(result.HitObject)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue