mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 15:22:55 +08:00
General refactoring
This commit is contained in:
parent
d686e841c5
commit
502e31dd37
@ -15,7 +15,6 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// List of <see cref="DifficultyHitObject"/>s that are encoded within this <see cref="MonoEncoding"/>.
|
||||
/// This is not declared as <see cref="TaikoDifficultyHitObject"/> to avoid circular dependencies.
|
||||
/// </summary>
|
||||
public List<TaikoDifficultyHitObject> EncodedData { get; private set; } = new List<TaikoDifficultyHitObject>();
|
||||
|
||||
|
@ -9,8 +9,7 @@ using osu.Game.Rulesets.Taiko.Objects;
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class to perform various encodings. This is separated out from the encoding classes to prevent circular
|
||||
/// dependencies.
|
||||
/// Utility class to perform various encodings.
|
||||
/// </summary>
|
||||
public class TaikoColourDifficultyPreprocessor
|
||||
{
|
||||
@ -26,7 +25,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
|
||||
// Assign indexing and encoding data to all relevant objects. Only the first note of each encoding type is
|
||||
// assigned with the relevant encodings.
|
||||
encodings.ForEach(coupledEncoding =>
|
||||
foreach (var coupledEncoding in encodings)
|
||||
{
|
||||
coupledEncoding.Payload[0].Payload[0].EncodedData[0].Colour.CoupledColourEncoding = coupledEncoding;
|
||||
|
||||
@ -48,7 +47,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
monoEncoding.EncodedData[0].Colour.MonoEncoding = monoEncoding;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return colours;
|
||||
}
|
||||
@ -58,35 +57,29 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
/// </summary>
|
||||
public static List<MonoEncoding> EncodeMono(List<DifficultyHitObject> data)
|
||||
{
|
||||
List<MonoEncoding> encoded = new List<MonoEncoding>();
|
||||
|
||||
MonoEncoding? lastEncoded = null;
|
||||
List<MonoEncoding> encodings = new List<MonoEncoding>();
|
||||
MonoEncoding? currentEncoding = null;
|
||||
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
TaikoDifficultyHitObject taikoObject = (TaikoDifficultyHitObject)data[i];
|
||||
|
||||
// This ignores all non-note objects, which may or may not be the desired behaviour
|
||||
TaikoDifficultyHitObject? previousObject = taikoObject.PreviousNote(0);
|
||||
|
||||
// If the colour changed or if this is the first object in the run, create a new mono encoding
|
||||
if
|
||||
(
|
||||
previousObject == null || // First object in the list
|
||||
(taikoObject.BaseObject as Hit)?.Type != (previousObject.BaseObject as Hit)?.Type
|
||||
)
|
||||
// If this is the first object in the list or the colour changed, create a new mono encoding
|
||||
if (currentEncoding == null || (taikoObject.BaseObject as Hit)?.Type != (previousObject?.BaseObject as Hit)?.Type)
|
||||
{
|
||||
lastEncoded = new MonoEncoding();
|
||||
lastEncoded.EncodedData.Add(taikoObject);
|
||||
encoded.Add(lastEncoded);
|
||||
currentEncoding = new MonoEncoding();
|
||||
encodings.Add(currentEncoding);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we're here, we're in the same encoding as the previous object, thus lastEncoded is not null.
|
||||
// Add the current object to the encoded payload.
|
||||
lastEncoded!.EncodedData.Add(taikoObject);
|
||||
currentEncoding.EncodedData.Add(taikoObject);
|
||||
}
|
||||
|
||||
return encoded;
|
||||
return encodings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -94,27 +87,24 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
/// </summary>
|
||||
public static List<ColourEncoding> EncodeColour(List<MonoEncoding> data)
|
||||
{
|
||||
List<ColourEncoding> encoded = new List<ColourEncoding>();
|
||||
ColourEncoding? lastEncoded = null;
|
||||
List<ColourEncoding> encodings = new List<ColourEncoding>();
|
||||
ColourEncoding? currentEncoding = null;
|
||||
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
// Starts a new ColourEncoding if the previous MonoEncoding has a different mono length, or if this is
|
||||
// the first MonoEncoding in the list.
|
||||
if (lastEncoded == null || data[i].RunLength != data[i - 1].RunLength)
|
||||
// Start a new ColourEncoding if the previous MonoEncoding has a different mono length, or if this is the first MonoEncoding in the list.
|
||||
if (currentEncoding == null || data[i].RunLength != data[i - 1].RunLength)
|
||||
{
|
||||
lastEncoded = new ColourEncoding();
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
encoded.Add(lastEncoded);
|
||||
currentEncoding = new ColourEncoding();
|
||||
encodings.Add(currentEncoding);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we're here, we're in the same encoding as the previous object. Add the current MonoEncoding to the
|
||||
// encoded payload.
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
// Add the current MonoEncoding to the encoded payload.
|
||||
currentEncoding.Payload.Add(data[i]);
|
||||
}
|
||||
|
||||
return encoded;
|
||||
return encodings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -122,16 +112,15 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
/// </summary>
|
||||
public static List<CoupledColourEncoding> EncodeCoupledColour(List<ColourEncoding> data)
|
||||
{
|
||||
List<CoupledColourEncoding> encoded = new List<CoupledColourEncoding>();
|
||||
CoupledColourEncoding? lastEncoded = null;
|
||||
List<CoupledColourEncoding> encodings = new List<CoupledColourEncoding>();
|
||||
CoupledColourEncoding? currentEncoding = null;
|
||||
|
||||
for (int i = 0; i < data.Count; i++)
|
||||
{
|
||||
// Starts a new CoupledColourEncoding. ColourEncodings that should be grouped together will be handled
|
||||
// later within this loop.
|
||||
lastEncoded = new CoupledColourEncoding
|
||||
// Start a new CoupledColourEncoding. ColourEncodings that should be grouped together will be handled later within this loop.
|
||||
currentEncoding = new CoupledColourEncoding
|
||||
{
|
||||
Previous = lastEncoded
|
||||
Previous = currentEncoding
|
||||
};
|
||||
|
||||
// Determine if future ColourEncodings should be grouped.
|
||||
@ -140,7 +129,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
if (!isCoupled)
|
||||
{
|
||||
// If not, add the current ColourEncoding to the encoded payload and continue.
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
currentEncoding.Payload.Add(data[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -148,27 +137,27 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
// subsequent ColourEncodings should be grouped by increasing i and doing the appropriate isCoupled check.
|
||||
while (isCoupled)
|
||||
{
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
currentEncoding.Payload.Add(data[i]);
|
||||
i++;
|
||||
isCoupled = i < data.Count - 2 && data[i].IsRepetitionOf(data[i + 2]);
|
||||
}
|
||||
|
||||
// Skip over viewed data and add the rest to the payload
|
||||
lastEncoded.Payload.Add(data[i]);
|
||||
lastEncoded.Payload.Add(data[i + 1]);
|
||||
currentEncoding.Payload.Add(data[i]);
|
||||
currentEncoding.Payload.Add(data[i + 1]);
|
||||
i++;
|
||||
}
|
||||
|
||||
encoded.Add(lastEncoded);
|
||||
encodings.Add(currentEncoding);
|
||||
}
|
||||
|
||||
// Final pass to find repetition intervals
|
||||
for (int i = 0; i < encoded.Count; i++)
|
||||
for (int i = 0; i < encodings.Count; i++)
|
||||
{
|
||||
encoded[i].FindRepetitionInterval();
|
||||
encodings[i].FindRepetitionInterval();
|
||||
}
|
||||
|
||||
return encoded;
|
||||
return encodings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -11,20 +11,17 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
|
||||
public class TaikoDifficultyHitObjectColour
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="MonoEncoding"/> encoding that encodes this note, only present if this is the first note within a
|
||||
/// <see cref="MonoEncoding"/>
|
||||
/// The <see cref="MonoEncoding"/> that encodes this note, only present if this is the first note within a <see cref="MonoEncoding"/>
|
||||
/// </summary>
|
||||
public MonoEncoding? MonoEncoding;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="ColourEncoding"/> encoding that encodes this note, only present if this is the first note within
|
||||
/// a <see cref="ColourEncoding"/>
|
||||
/// The <see cref="ColourEncoding"/> that encodes this note, only present if this is the first note within a <see cref="ColourEncoding"/>
|
||||
/// </summary>
|
||||
public ColourEncoding? ColourEncoding;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="CoupledColourEncoding"/> encoding that encodes this note, only present if this is the first note
|
||||
/// within a <see cref="CoupledColourEncoding"/>
|
||||
/// The <see cref="CoupledColourEncoding"/> that encodes this note, only present if this is the first note within a <see cref="CoupledColourEncoding"/>
|
||||
/// </summary>
|
||||
public CoupledColourEncoding? CoupledColourEncoding;
|
||||
}
|
||||
|
@ -45,9 +45,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
/// <summary>
|
||||
/// Colour data for this hit object. This is used by colour evaluator to calculate colour difficulty, but can be used
|
||||
/// by other skills in the future.
|
||||
/// This need to be writeable by TaikoDifficultyHitObjectColour so that it can assign potentially reused instances
|
||||
/// </summary>
|
||||
public TaikoDifficultyHitObjectColour Colour;
|
||||
public readonly TaikoDifficultyHitObjectColour Colour;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new difficulty hit object.
|
||||
@ -59,7 +58,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
/// <param name="objects">The list of all <see cref="DifficultyHitObject"/>s in the current beatmap.</param>
|
||||
/// <param name="centreHitObjects">The list of centre (don) <see cref="DifficultyHitObject"/>s in the current beatmap.</param>
|
||||
/// <param name="rimHitObjects">The list of rim (kat) <see cref="DifficultyHitObject"/>s in the current beatmap.</param>
|
||||
/// <param name="noteObjects">The list of <see cref="DifficultyHitObject"/>s that is a hit (i.e. not a slider or spinner) in the current beatmap.</param>
|
||||
/// <param name="noteObjects">The list of <see cref="DifficultyHitObject"/>s that is a hit (i.e. not a drumroll or swell) in the current beatmap.</param>
|
||||
/// <param name="index">The position of this <see cref="DifficultyHitObject"/> in the <paramref name="objects"/> list.</param>
|
||||
public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate,
|
||||
List<DifficultyHitObject> objects,
|
||||
@ -68,33 +67,31 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
List<TaikoDifficultyHitObject> noteObjects, int index)
|
||||
: base(hitObject, lastObject, clockRate, objects, index)
|
||||
{
|
||||
// Create the Colour object, its properties should be filled in by TaikoDifficultyPreprocessor
|
||||
Colour = new TaikoDifficultyHitObjectColour();
|
||||
|
||||
var currentHit = hitObject as Hit;
|
||||
noteDifficultyHitObjects = noteObjects;
|
||||
|
||||
// Create the Colour object, its properties should be filled in by TaikoDifficultyPreprocessor
|
||||
Colour = new TaikoDifficultyHitObjectColour();
|
||||
Rhythm = getClosestRhythm(lastObject, lastLastObject, clockRate);
|
||||
HitType? hitType = currentHit?.Type;
|
||||
|
||||
if (hitType == HitType.Centre)
|
||||
switch ((hitObject as Hit)?.Type)
|
||||
{
|
||||
MonoIndex = centreHitObjects.Count;
|
||||
centreHitObjects.Add(this);
|
||||
monoDifficultyHitObjects = centreHitObjects;
|
||||
}
|
||||
else if (hitType == HitType.Rim)
|
||||
{
|
||||
MonoIndex = rimHitObjects.Count;
|
||||
rimHitObjects.Add(this);
|
||||
monoDifficultyHitObjects = rimHitObjects;
|
||||
}
|
||||
case HitType.Centre:
|
||||
MonoIndex = centreHitObjects.Count;
|
||||
centreHitObjects.Add(this);
|
||||
monoDifficultyHitObjects = centreHitObjects;
|
||||
break;
|
||||
|
||||
// Need to be done after HitType is set.
|
||||
if (hitType == null) return;
|
||||
case HitType.Rim:
|
||||
MonoIndex = rimHitObjects.Count;
|
||||
rimHitObjects.Add(this);
|
||||
monoDifficultyHitObjects = rimHitObjects;
|
||||
break;
|
||||
|
||||
NoteIndex = noteObjects.Count;
|
||||
noteObjects.Add(this);
|
||||
default:
|
||||
NoteIndex = noteObjects.Count;
|
||||
noteObjects.Add(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Difficulty.Skills;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
Loading…
Reference in New Issue
Block a user