mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Reimplement as extension method on IBeatmap
Implementation has changed slightly to support arbitrary levels of nested hitobjects.
This commit is contained in:
parent
74a55ead77
commit
215da7e933
@ -9,7 +9,6 @@ using osu.Game.Rulesets.Difficulty;
|
|||||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||||
using osu.Game.Rulesets.Difficulty.Skills;
|
using osu.Game.Rulesets.Difficulty.Skills;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
||||||
using osu.Game.Rulesets.Osu.Difficulty.Skills;
|
using osu.Game.Rulesets.Osu.Difficulty.Skills;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
@ -62,21 +61,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
|
|||||||
|
|
||||||
double preempt = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450) / clockRate;
|
double preempt = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450) / clockRate;
|
||||||
double drainRate = beatmap.Difficulty.DrainRate;
|
double drainRate = beatmap.Difficulty.DrainRate;
|
||||||
|
int maxCombo = beatmap.GetMaxCombo();
|
||||||
int maxCombo = 0;
|
|
||||||
|
|
||||||
void countCombo(HitObject ho)
|
|
||||||
{
|
|
||||||
if (ho.CreateJudgement().MaxResult.AffectsCombo())
|
|
||||||
maxCombo++;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (HitObject ho in beatmap.HitObjects)
|
|
||||||
{
|
|
||||||
countCombo(ho);
|
|
||||||
foreach (HitObject nested in ho.NestedHitObjects)
|
|
||||||
countCombo(nested);
|
|
||||||
}
|
|
||||||
|
|
||||||
int hitCirclesCount = beatmap.HitObjects.Count(h => h is HitCircle);
|
int hitCirclesCount = beatmap.HitObjects.Count(h => h is HitCircle);
|
||||||
int sliderCount = beatmap.HitObjects.Count(h => h is Slider);
|
int sliderCount = beatmap.HitObjects.Count(h => h is Slider);
|
||||||
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
@ -70,4 +71,27 @@ namespace osu.Game.Beatmaps
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
new IReadOnlyList<T> HitObjects { get; }
|
new IReadOnlyList<T> HitObjects { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class BeatmapExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Finds the maximum achievable combo by hitting all <see cref="HitObject"/>s in a beatmap.
|
||||||
|
/// </summary>
|
||||||
|
public static int GetMaxCombo(this IBeatmap beatmap)
|
||||||
|
{
|
||||||
|
int combo = 0;
|
||||||
|
foreach (var h in beatmap.HitObjects)
|
||||||
|
addCombo(h, ref combo);
|
||||||
|
return combo;
|
||||||
|
|
||||||
|
static void addCombo(HitObject hitObject, ref int combo)
|
||||||
|
{
|
||||||
|
if (hitObject.CreateJudgement().MaxResult.AffectsCombo())
|
||||||
|
combo++;
|
||||||
|
|
||||||
|
foreach (var nested in hitObject.NestedHitObjects)
|
||||||
|
addCombo(nested, ref combo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user