1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 23:32:55 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/Colour/ColourEncoding.cs

42 lines
1.4 KiB
C#

using System.Collections.Generic;
using osu.Game.Rulesets.Difficulty.Preprocessing;
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
{
public class ColourEncoding
{
public List<MonoEncoding> Payload { get; private set; } = new List<MonoEncoding>();
public bool isIdenticalTo(ColourEncoding other)
{
return other.Payload[0].RunLength == Payload[0].RunLength &&
other.Payload[0].EncodedData[0].HitType == Payload[0].EncodedData[0].HitType;
}
public bool hasIdenticalMonoLength(ColourEncoding other)
{
return other.Payload[0].RunLength == Payload[0].RunLength;
}
public static List<ColourEncoding> Encode(List<MonoEncoding> data)
{
// Compute encoding lengths
List<ColourEncoding> encoded = new List<ColourEncoding>();
ColourEncoding? lastEncoded = null;
for (int i = 0; i < data.Count; i++)
{
if (i == 0 || lastEncoded == null || data[i].RunLength != data[i - 1].RunLength)
{
lastEncoded = new ColourEncoding();
lastEncoded.Payload.Add(data[i]);
encoded.Add(lastEncoded);
continue;
}
lastEncoded.Payload.Add(data[i]);
}
return encoded;
}
}
}