1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 00:53:20 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/Colour/Data/ColourEncoding.cs
Dan Balasescu 94c6beeaf7 Use ctor in a place that looks visually weird
I read through this thinking "why doesn't Previous get assigned to
currentEncoding here? But it's because the initializer runs right after
the ctor and before the "method" returns. So really there's 3 operations
running on one line here - ctor, init, and assignment.
2022-08-15 21:30:46 +09:00

51 lines
2.0 KiB
C#

// 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.
using System.Collections.Generic;
using osu.Game.Rulesets.Taiko.Objects;
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
{
/// <summary>
/// Encodes a list of <see cref="MonoEncoding"/>s.
/// <see cref="MonoEncoding"/>s with the same <see cref="MonoEncoding.RunLength"/> are grouped together.
/// </summary>
public class ColourEncoding
{
/// <summary>
/// <see cref="MonoEncoding"/>s that are grouped together within this <see cref="ColourEncoding"/>.
/// </summary>
public readonly List<MonoEncoding> Payload = new List<MonoEncoding>();
/// <summary>
/// The parent <see cref="CoupledColourEncoding"/> that contains this <see cref="ColourEncoding"/>
/// </summary>
public CoupledColourEncoding? Parent;
/// <summary>
/// Index of this encoding within it's parent encoding
/// </summary>
public int Index;
/// <summary>
/// Determine if this <see cref="ColourEncoding"/> is a repetition of another <see cref="ColourEncoding"/>. This
/// is a strict comparison and is true if and only if the colour sequence is exactly the same.
/// </summary>
public bool IsRepetitionOf(ColourEncoding other)
{
return HasIdenticalMonoLength(other) &&
other.Payload.Count == Payload.Count &&
(other.Payload[0].EncodedData[0].BaseObject as Hit)?.Type ==
(Payload[0].EncodedData[0].BaseObject as Hit)?.Type;
}
/// <summary>
/// Determine if this <see cref="ColourEncoding"/> has the same mono length of another <see cref="ColourEncoding"/>.
/// </summary>
public bool HasIdenticalMonoLength(ColourEncoding other)
{
return other.Payload[0].RunLength == Payload[0].RunLength;
}
}
}