1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-21 06:42:54 +08:00

Use switch statement for type matching

This commit is contained in:
Dean Herbert 2023-11-17 18:45:16 +09:00
parent a556caae43
commit 2ab84fdaa3
No known key found for this signature in database

View File

@ -99,15 +99,21 @@ namespace osu.Game.Rulesets.Osu.Scoring
double hpOverkill = Math.Max(0, hpReduction - currentHp); double hpOverkill = Math.Max(0, hpReduction - currentHp);
reduceHp(hpReduction); reduceHp(hpReduction);
if (h is Slider slider) switch (h)
{
case Slider slider:
{ {
foreach (var nested in slider.NestedHitObjects) foreach (var nested in slider.NestedHitObjects)
increaseHp(nested); increaseHp(nested);
break;
} }
else if (h is Spinner spinner)
case Spinner spinner:
{ {
foreach (var nested in spinner.NestedHitObjects.Where(t => t is not SpinnerBonusTick)) foreach (var nested in spinner.NestedHitObjects.Where(t => t is not SpinnerBonusTick))
increaseHp(nested); increaseHp(nested);
break;
}
} }
// Note: Because HP is capped during the above increases, long sliders (with many ticks) or spinners // Note: Because HP is capped during the above increases, long sliders (with many ticks) or spinners