mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Avoid passing down rhythm list every time
This commit is contained in:
parent
27f97973ee
commit
ec99fcd7ab
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -19,23 +18,35 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
|||||||
|
|
||||||
public readonly int ObjectIndex;
|
public readonly int ObjectIndex;
|
||||||
|
|
||||||
public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate, int objectIndex,
|
public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate, int objectIndex)
|
||||||
IEnumerable<TaikoDifficultyHitObjectRhythm> commonRhythms)
|
|
||||||
: base(hitObject, lastObject, clockRate)
|
: base(hitObject, lastObject, clockRate)
|
||||||
{
|
{
|
||||||
var currentHit = hitObject as Hit;
|
var currentHit = hitObject as Hit;
|
||||||
|
|
||||||
double prevLength = (lastObject.StartTime - lastLastObject.StartTime) / clockRate;
|
double prevLength = (lastObject.StartTime - lastLastObject.StartTime) / clockRate;
|
||||||
|
|
||||||
Rhythm = getClosestRhythm(DeltaTime / prevLength, commonRhythms);
|
Rhythm = getClosestRhythm(DeltaTime / prevLength);
|
||||||
HitType = currentHit?.Type;
|
HitType = currentHit?.Type;
|
||||||
|
|
||||||
ObjectIndex = objectIndex;
|
ObjectIndex = objectIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaikoDifficultyHitObjectRhythm getClosestRhythm(double ratio, IEnumerable<TaikoDifficultyHitObjectRhythm> commonRhythms)
|
private static readonly TaikoDifficultyHitObjectRhythm[] common_rhythms =
|
||||||
{
|
{
|
||||||
return commonRhythms.OrderBy(x => Math.Abs(x.Ratio - ratio)).First();
|
new TaikoDifficultyHitObjectRhythm(1, 1, 0.0),
|
||||||
|
new TaikoDifficultyHitObjectRhythm(2, 1, 0.3),
|
||||||
|
new TaikoDifficultyHitObjectRhythm(1, 2, 0.5),
|
||||||
|
new TaikoDifficultyHitObjectRhythm(3, 1, 0.3),
|
||||||
|
new TaikoDifficultyHitObjectRhythm(1, 3, 0.35),
|
||||||
|
new TaikoDifficultyHitObjectRhythm(3, 2, 0.6),
|
||||||
|
new TaikoDifficultyHitObjectRhythm(2, 3, 0.4),
|
||||||
|
new TaikoDifficultyHitObjectRhythm(5, 4, 0.5),
|
||||||
|
new TaikoDifficultyHitObjectRhythm(4, 5, 0.7)
|
||||||
|
};
|
||||||
|
|
||||||
|
private TaikoDifficultyHitObjectRhythm getClosestRhythm(double ratio)
|
||||||
|
{
|
||||||
|
return common_rhythms.OrderBy(x => Math.Abs(x.Ratio - ratio)).First();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,19 +24,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
|
|||||||
private const double colour_skill_multiplier = 0.01;
|
private const double colour_skill_multiplier = 0.01;
|
||||||
private const double stamina_skill_multiplier = 0.02;
|
private const double stamina_skill_multiplier = 0.02;
|
||||||
|
|
||||||
private readonly TaikoDifficultyHitObjectRhythm[] commonRhythms =
|
|
||||||
{
|
|
||||||
new TaikoDifficultyHitObjectRhythm(1, 1, 0.0),
|
|
||||||
new TaikoDifficultyHitObjectRhythm(2, 1, 0.3),
|
|
||||||
new TaikoDifficultyHitObjectRhythm(1, 2, 0.5),
|
|
||||||
new TaikoDifficultyHitObjectRhythm(3, 1, 0.3),
|
|
||||||
new TaikoDifficultyHitObjectRhythm(1, 3, 0.35),
|
|
||||||
new TaikoDifficultyHitObjectRhythm(3, 2, 0.6),
|
|
||||||
new TaikoDifficultyHitObjectRhythm(2, 3, 0.4),
|
|
||||||
new TaikoDifficultyHitObjectRhythm(5, 4, 0.5),
|
|
||||||
new TaikoDifficultyHitObjectRhythm(4, 5, 0.7)
|
|
||||||
};
|
|
||||||
|
|
||||||
public TaikoDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
public TaikoDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
@ -135,7 +122,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
|
|||||||
{
|
{
|
||||||
taikoDifficultyHitObjects.Add(
|
taikoDifficultyHitObjects.Add(
|
||||||
new TaikoDifficultyHitObject(
|
new TaikoDifficultyHitObject(
|
||||||
beatmap.HitObjects[i], beatmap.HitObjects[i - 1], beatmap.HitObjects[i - 2], clockRate, i, commonRhythms
|
beatmap.HitObjects[i], beatmap.HitObjects[i - 1], beatmap.HitObjects[i - 2], clockRate, i
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user