1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:17:51 +08:00

fixed mentioned issues

This commit is contained in:
Givikap120 2024-08-19 17:44:05 +03:00
parent 8b6106c2fe
commit 29bf1637b9
5 changed files with 53 additions and 57 deletions

View File

@ -82,25 +82,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty
double preempt = IBeatmapDifficultyInfo.DifficultyRange(beatmap.Difficulty.ApproachRate, 1800, 1200, 450) / clockRate;
double drainRate = beatmap.Difficulty.DrainRate;
int maxCombo;
int hitCirclesCount, sliderCount, spinnerCount;
int maxCombo = beatmap.GetMaxCombo();
if (beatmap is ProgressiveCalculationBeatmap pcBeatmap)
{
maxCombo = pcBeatmap.GetMaxCombo();
hitCirclesCount = pcBeatmap.GetHitObjectCountOf(typeof(HitCircle));
sliderCount = pcBeatmap.GetHitObjectCountOf(typeof(Slider));
spinnerCount = pcBeatmap.GetHitObjectCountOf(typeof(Spinner));
}
else
{
maxCombo = beatmap.GetMaxCombo();
hitCirclesCount = beatmap.HitObjects.Count(h => h is HitCircle);
sliderCount = beatmap.HitObjects.Count(h => h is Slider);
spinnerCount = beatmap.HitObjects.Count(h => h is Spinner);
}
int hitCirclesCount = beatmap.GetHitObjectCountOf(typeof(HitCircle));
int sliderCount = beatmap.GetHitObjectCountOf(typeof(Slider));
int spinnerCount = beatmap.GetHitObjectCountOf(typeof(Spinner));
HitWindows hitWindows = new OsuHitWindows();
hitWindows.SetDifficulty(beatmap.Difficulty.OverallDifficulty);

View File

@ -10,6 +10,7 @@ using osu.Game.Beatmaps.ControlPoints;
using Newtonsoft.Json;
using osu.Framework.Lists;
using osu.Game.IO.Serialization.Converters;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Beatmaps
{
@ -115,6 +116,25 @@ namespace osu.Game.Beatmaps
return mostCommon.beatLength;
}
public int GetMaxCombo()
{
int combo = 0;
foreach (var h in HitObjects)
addCombo(h, ref combo);
return combo;
static void addCombo(HitObject hitObject, ref int combo)
{
if (hitObject.Judgement.MaxResult.AffectsCombo())
combo++;
foreach (var nested in hitObject.NestedHitObjects)
addCombo(nested, ref combo);
}
}
public int GetHitObjectCountOf(Type type) => HitObjects.Count(h => h.GetType() == type);
IBeatmap IBeatmap.Clone() => Clone();
public Beatmap<T> Clone() => (Beatmap<T>)MemberwiseClone();

View File

@ -8,7 +8,6 @@ using osu.Framework.Lists;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Beatmaps
{
@ -74,6 +73,16 @@ namespace osu.Game.Beatmaps
/// </summary>
/// <returns>The shallow-cloned beatmap.</returns>
IBeatmap Clone();
/// <summary>
/// Finds the maximum achievable combo by hitting all <see cref="HitObject"/>s in a beatmap.
/// </summary>
int GetMaxCombo();
/// <summary>
/// Finds amount of <see cref="HitObject"/>s that have given type.
/// </summary>
int GetHitObjectCountOf(Type type);
}
/// <summary>
@ -90,26 +99,6 @@ namespace osu.Game.Beatmaps
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.Judgement.MaxResult.AffectsCombo())
combo++;
foreach (var nested in hitObject.NestedHitObjects)
addCombo(nested, ref combo);
}
}
/// <summary>
/// Find the total milliseconds between the first and last hittable objects.
/// </summary>

View File

@ -303,6 +303,10 @@ namespace osu.Game.Rulesets.Difficulty
this.baseBeatmap = baseBeatmap;
}
private int maxCombo;
public int GetMaxCombo() => maxCombo;
public void AddHitObject(HitObject hitObject)
{
hitObjects.Add(hitObject);
@ -311,6 +315,17 @@ namespace osu.Game.Rulesets.Difficulty
if (!hitObjectsCounts.ContainsKey(objectType))
hitObjectsCounts[objectType] = 0; // Initialize to 0 if not present
hitObjectsCounts[objectType]++;
addCombo(hitObject);
void addCombo(HitObject hitObject)
{
if (hitObject.Judgement.MaxResult.AffectsCombo())
maxCombo++;
foreach (var nested in hitObject.NestedHitObjects)
addCombo(nested);
};
}
private readonly List<HitObject> hitObjects = new List<HitObject>();
@ -321,24 +336,6 @@ namespace osu.Game.Rulesets.Difficulty
IReadOnlyList<HitObject> IBeatmap.HitObjects => hitObjects;
private int comboObjectIndex, combo;
public int GetMaxCombo()
{
for (; comboObjectIndex < hitObjects.Count; comboObjectIndex++)
addCombo(hitObjects[comboObjectIndex], ref combo);
return combo;
static void addCombo(HitObject hitObject, ref int combo)
{
if (hitObject.Judgement.MaxResult.AffectsCombo())
combo++;
foreach (var nested in hitObject.NestedHitObjects)
addCombo(nested, ref combo);
}
}
#region Delegated IBeatmap implementation
public BeatmapInfo BeatmapInfo

View File

@ -198,6 +198,10 @@ namespace osu.Game.Screens.Edit
public double GetMostCommonBeatLength() => PlayableBeatmap.GetMostCommonBeatLength();
public int GetMaxCombo() => PlayableBeatmap.GetMaxCombo();
public int GetHitObjectCountOf(Type type) => PlayableBeatmap.GetHitObjectCountOf(type);
public IBeatmap Clone() => (EditorBeatmap)MemberwiseClone();
private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects;