mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:07:52 +08:00
Refactor to move first-object detection to evaluation
This commit is contained in:
parent
f318452510
commit
d84c956af9
@ -54,12 +54,12 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
|
||||
TaikoDifficultyHitObjectColour colour = ((TaikoDifficultyHitObject)hitObject).Colour;
|
||||
double difficulty = 0.0d;
|
||||
|
||||
if (colour.MonoStreak != null) // Difficulty for MonoStreak
|
||||
difficulty += EvaluateDifficultyOf(colour.MonoStreak);
|
||||
if (colour.AlternatingMonoPattern != null) // Difficulty for AlternatingMonoPattern
|
||||
difficulty += EvaluateDifficultyOf(colour.AlternatingMonoPattern);
|
||||
if (colour.RepeatingHitPattern != null) // Difficulty for RepeatingHitPattern
|
||||
difficulty += EvaluateDifficultyOf(colour.RepeatingHitPattern);
|
||||
if (colour.MonoStreak?.FirstHitObject == hitObject) // Difficulty for MonoStreak
|
||||
difficulty += EvaluateDifficultyOf(colour.MonoStreak!);
|
||||
if (colour.AlternatingMonoPattern?.FirstHitObject == hitObject) // Difficulty for AlternatingMonoPattern
|
||||
difficulty += EvaluateDifficultyOf(colour.AlternatingMonoPattern!);
|
||||
if (colour.RepeatingHitPattern?.FirstHitObject == hitObject) // Difficulty for RepeatingHitPattern
|
||||
difficulty += EvaluateDifficultyOf(colour.RepeatingHitPattern!);
|
||||
|
||||
return difficulty;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
|
||||
{
|
||||
@ -31,6 +32,11 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
|
||||
/// </summary>
|
||||
public TaikoDifficultyHitObject FirstHitObject => MonoStreaks[0].FirstHitObject;
|
||||
|
||||
/// <summary>
|
||||
/// All <see cref="TaikoDifficultyHitObject"/>s in this <see cref="AlternatingMonoPattern"/>.
|
||||
/// </summary>
|
||||
public IEnumerable<TaikoDifficultyHitObject> AllHitObjects => MonoStreaks.SelectMany(streak => streak.HitObjects);
|
||||
|
||||
/// <summary>
|
||||
/// Determine if this <see cref="AlternatingMonoPattern"/> is a repetition of another <see cref="AlternatingMonoPattern"/>. This
|
||||
/// is a strict comparison and is true if and only if the colour sequence is exactly the same.
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
|
||||
@ -23,10 +24,15 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
|
||||
public readonly List<AlternatingMonoPattern> AlternatingMonoPatterns = new List<AlternatingMonoPattern>();
|
||||
|
||||
/// <summary>
|
||||
/// The parent <see cref="TaikoDifficultyHitObject"/> in this <see cref="RepeatingHitPatterns"/>
|
||||
/// The first <see cref="TaikoDifficultyHitObject"/> in this <see cref="RepeatingHitPatterns"/>
|
||||
/// </summary>
|
||||
public TaikoDifficultyHitObject FirstHitObject => AlternatingMonoPatterns[0].FirstHitObject;
|
||||
|
||||
/// <summary>
|
||||
/// All <see cref="TaikoDifficultyHitObject"/>s in this <see cref="RepeatingHitPatterns"/>.
|
||||
/// </summary>
|
||||
public IEnumerable<TaikoDifficultyHitObject> AllHitObjects => AlternatingMonoPatterns.SelectMany(pattern => pattern.AllHitObjects);
|
||||
|
||||
/// <summary>
|
||||
/// The previous <see cref="RepeatingHitPatterns"/>. This is used to determine the repetition interval.
|
||||
/// </summary>
|
||||
|
@ -15,18 +15,19 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
{
|
||||
/// <summary>
|
||||
/// Processes and encodes a list of <see cref="TaikoDifficultyHitObject"/>s into a list of <see cref="TaikoDifficultyHitObjectColour"/>s,
|
||||
/// assigning the appropriate <see cref="TaikoDifficultyHitObjectColour"/>s to each <see cref="TaikoDifficultyHitObject"/>,
|
||||
/// and pre-evaluating colour difficulty of each <see cref="TaikoDifficultyHitObject"/>.
|
||||
/// assigning the appropriate <see cref="TaikoDifficultyHitObjectColour"/>s to each <see cref="TaikoDifficultyHitObject"/>.
|
||||
/// </summary>
|
||||
public static void ProcessAndAssign(List<DifficultyHitObject> hitObjects)
|
||||
{
|
||||
List<RepeatingHitPatterns> hitPatterns = encode(hitObjects);
|
||||
|
||||
// Assign indexing and encoding data to all relevant objects. Only the first note of each encoding type is
|
||||
// assigned with the relevant encodings.
|
||||
// Assign indexing and encoding data to all relevant objects.
|
||||
foreach (var repeatingHitPattern in hitPatterns)
|
||||
{
|
||||
repeatingHitPattern.FirstHitObject.Colour.RepeatingHitPattern = repeatingHitPattern;
|
||||
foreach (var hitObject in repeatingHitPattern.AllHitObjects)
|
||||
{
|
||||
hitObject.Colour.RepeatingHitPattern = repeatingHitPattern;
|
||||
}
|
||||
|
||||
// The outermost loop is kept a ForEach loop since it doesn't need index information, and we want to
|
||||
// keep i and j for AlternatingMonoPattern's and MonoStreak's index respectively, to keep it in line with
|
||||
@ -36,14 +37,22 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
AlternatingMonoPattern monoPattern = repeatingHitPattern.AlternatingMonoPatterns[i];
|
||||
monoPattern.Parent = repeatingHitPattern;
|
||||
monoPattern.Index = i;
|
||||
monoPattern.FirstHitObject.Colour.AlternatingMonoPattern = monoPattern;
|
||||
|
||||
foreach (var hitObject in monoPattern.AllHitObjects)
|
||||
{
|
||||
hitObject.Colour.AlternatingMonoPattern = monoPattern;
|
||||
}
|
||||
|
||||
for (int j = 0; j < monoPattern.MonoStreaks.Count; ++j)
|
||||
{
|
||||
MonoStreak monoStreak = monoPattern.MonoStreaks[j];
|
||||
monoStreak.Parent = monoPattern;
|
||||
monoStreak.Index = j;
|
||||
monoStreak.FirstHitObject.Colour.MonoStreak = monoStreak;
|
||||
|
||||
foreach (var hitObject in monoStreak.HitObjects)
|
||||
{
|
||||
hitObject.Colour.MonoStreak = monoStreak;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,17 +11,17 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
public class TaikoDifficultyHitObjectColour
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="MonoStreak"/> that encodes this note, only present if this is the first note within a <see cref="MonoStreak"/>
|
||||
/// The <see cref="MonoStreak"/> that encodes this note.
|
||||
/// </summary>
|
||||
public MonoStreak? MonoStreak;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="AlternatingMonoPattern"/> that encodes this note, only present if this is the first note within a <see cref="AlternatingMonoPattern"/>
|
||||
/// The <see cref="AlternatingMonoPattern"/> that encodes this note.
|
||||
/// </summary>
|
||||
public AlternatingMonoPattern? AlternatingMonoPattern;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RepeatingHitPattern"/> that encodes this note, only present if this is the first note within a <see cref="RepeatingHitPattern"/>
|
||||
/// The <see cref="RepeatingHitPattern"/> that encodes this note.
|
||||
/// </summary>
|
||||
public RepeatingHitPatterns? RepeatingHitPattern;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user