1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 08:13:31 +08:00

Remove ControlPoint.EquivalentTo

This commit is contained in:
smoogipoo 2019-05-21 14:27:57 +09:00
parent 7e38aabe75
commit 7a56fe84f2
6 changed files with 26 additions and 37 deletions

View File

@ -19,15 +19,7 @@ namespace osu.Game.Beatmaps.ControlPoints
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time); public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
/// <summary>
/// Whether this <see cref="ControlPoint"/> provides the same parametric changes as another <see cref="ControlPoint"/>.
/// Basically an equality check without considering the <see cref="Time"/>.
/// </summary>
/// <param name="other">The <see cref="ControlPoint"/> to compare to.</param>
/// <returns>Whether this <see cref="ControlPoint"/> is equivalent to <paramref name="other"/>.</returns>
public virtual bool EquivalentTo(ControlPoint other) => true;
public bool Equals(ControlPoint other) public bool Equals(ControlPoint other)
=> EquivalentTo(other) && Time.Equals(other?.Time); => Time.Equals(other?.Time);
} }
} }

View File

@ -1,11 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osuTK; using osuTK;
namespace osu.Game.Beatmaps.ControlPoints namespace osu.Game.Beatmaps.ControlPoints
{ {
public class DifficultyControlPoint : ControlPoint public class DifficultyControlPoint : ControlPoint, IEquatable<DifficultyControlPoint>
{ {
/// <summary> /// <summary>
/// The speed multiplier at this control point. /// The speed multiplier at this control point.
@ -18,9 +19,8 @@ namespace osu.Game.Beatmaps.ControlPoints
private double speedMultiplier = 1; private double speedMultiplier = 1;
public override bool EquivalentTo(ControlPoint other) public bool Equals(DifficultyControlPoint other)
=> base.EquivalentTo(other) => base.Equals(other)
&& other is DifficultyControlPoint difficulty && SpeedMultiplier.Equals(other?.SpeedMultiplier);
&& SpeedMultiplier.Equals(difficulty.SpeedMultiplier);
} }
} }

View File

@ -1,9 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
namespace osu.Game.Beatmaps.ControlPoints namespace osu.Game.Beatmaps.ControlPoints
{ {
public class EffectControlPoint : ControlPoint public class EffectControlPoint : ControlPoint, IEquatable<EffectControlPoint>
{ {
/// <summary> /// <summary>
/// Whether this control point enables Kiai mode. /// Whether this control point enables Kiai mode.
@ -15,10 +17,8 @@ namespace osu.Game.Beatmaps.ControlPoints
/// </summary> /// </summary>
public bool OmitFirstBarLine; public bool OmitFirstBarLine;
public override bool EquivalentTo(ControlPoint other) public bool Equals(EffectControlPoint other)
=> base.EquivalentTo(other) => base.Equals(other)
&& other is EffectControlPoint effect && KiaiMode == other?.KiaiMode && OmitFirstBarLine == other.OmitFirstBarLine;
&& KiaiMode.Equals(effect.KiaiMode)
&& OmitFirstBarLine.Equals(effect.OmitFirstBarLine);
} }
} }

View File

@ -1,11 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Game.Audio; using osu.Game.Audio;
namespace osu.Game.Beatmaps.ControlPoints namespace osu.Game.Beatmaps.ControlPoints
{ {
public class SampleControlPoint : ControlPoint public class SampleControlPoint : ControlPoint, IEquatable<SampleControlPoint>
{ {
public const string DEFAULT_BANK = "normal"; public const string DEFAULT_BANK = "normal";
@ -44,10 +45,8 @@ namespace osu.Game.Beatmaps.ControlPoints
return newSampleInfo; return newSampleInfo;
} }
public override bool EquivalentTo(ControlPoint other) public bool Equals(SampleControlPoint other)
=> base.EquivalentTo(other) => base.Equals(other)
&& other is SampleControlPoint sample && string.Equals(SampleBank, other?.SampleBank) && SampleVolume == other?.SampleVolume;
&& SampleBank.Equals(sample.SampleBank)
&& SampleVolume.Equals(sample.SampleVolume);
} }
} }

View File

@ -1,12 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osuTK; using osuTK;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
namespace osu.Game.Beatmaps.ControlPoints namespace osu.Game.Beatmaps.ControlPoints
{ {
public class TimingControlPoint : ControlPoint public class TimingControlPoint : ControlPoint, IEquatable<TimingControlPoint>
{ {
/// <summary> /// <summary>
/// The time signature at this control point. /// The time signature at this control point.
@ -24,10 +25,8 @@ namespace osu.Game.Beatmaps.ControlPoints
private double beatLength = 1000; private double beatLength = 1000;
public override bool EquivalentTo(ControlPoint other) public bool Equals(TimingControlPoint other)
=> base.EquivalentTo(other) => base.Equals(other)
&& other is TimingControlPoint timing && TimeSignature == other?.TimeSignature && beatLength.Equals(other.beatLength);
&& TimeSignature.Equals(timing.TimeSignature)
&& BeatLength.Equals(timing.BeatLength);
} }
} }

View File

@ -189,7 +189,7 @@ namespace osu.Game.Beatmaps.Formats
Foreground = 3 Foreground = 3
} }
internal class LegacySampleControlPoint : SampleControlPoint internal class LegacySampleControlPoint : SampleControlPoint, IEquatable<LegacySampleControlPoint>
{ {
public int CustomSampleBank; public int CustomSampleBank;
@ -203,10 +203,9 @@ namespace osu.Game.Beatmaps.Formats
return baseInfo; return baseInfo;
} }
public override bool EquivalentTo(ControlPoint other) public bool Equals(LegacySampleControlPoint other)
=> base.EquivalentTo(other) => base.Equals(other)
&& other is LegacySampleControlPoint legacy && CustomSampleBank == other?.CustomSampleBank;
&& CustomSampleBank == legacy.CustomSampleBank;
} }
} }
} }