1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 05:42:54 +08:00

Remove EquivalentTo() and Equals()

This commit is contained in:
smoogipoo 2020-04-17 17:04:09 +09:00
parent eb968d2bdb
commit 69fb984e71
7 changed files with 20 additions and 35 deletions

View File

@ -5,7 +5,7 @@ using System;
namespace osu.Game.Beatmaps.ControlPoints namespace osu.Game.Beatmaps.ControlPoints
{ {
public abstract class ControlPoint : IComparable<ControlPoint>, IEquatable<ControlPoint> public abstract class ControlPoint : IComparable<ControlPoint>
{ {
/// <summary> /// <summary>
/// The time at which the control point takes effect. /// The time at which the control point takes effect.
@ -18,13 +18,6 @@ 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 control point is equivalent to another, ignoring time.
/// </summary>
/// <param name="other">Another control point to compare with.</param>
/// <returns>Whether equivalent.</returns>
public abstract bool EquivalentTo(ControlPoint other);
/// <summary> /// <summary>
/// Whether this control point results in a meaningful change when placed after another. /// Whether this control point results in a meaningful change when placed after another.
/// </summary> /// </summary>
@ -32,7 +25,5 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <param name="time">The time this control point will be placed at if it is added.</param> /// <param name="time">The time this control point will be placed at if it is added.</param>
/// <returns>Whether redundant.</returns> /// <returns>Whether redundant.</returns>
public abstract bool IsRedundant(ControlPoint existing, double time); public abstract bool IsRedundant(ControlPoint existing, double time);
public bool Equals(ControlPoint other) => Time == other?.Time && EquivalentTo(other);
} }
} }

View File

@ -27,9 +27,8 @@ namespace osu.Game.Beatmaps.ControlPoints
set => SpeedMultiplierBindable.Value = value; set => SpeedMultiplierBindable.Value = value;
} }
public override bool EquivalentTo(ControlPoint other) => public override bool IsRedundant(ControlPoint existing, double time)
other is DifficultyControlPoint otherTyped && otherTyped.SpeedMultiplier.Equals(SpeedMultiplier); => existing is DifficultyControlPoint existingDifficulty
&& SpeedMultiplier == existingDifficulty.SpeedMultiplier;
public override bool IsRedundant(ControlPoint existing, double time) => EquivalentTo(existing);
} }
} }

View File

@ -35,10 +35,10 @@ namespace osu.Game.Beatmaps.ControlPoints
set => KiaiModeBindable.Value = value; set => KiaiModeBindable.Value = value;
} }
public override bool EquivalentTo(ControlPoint other) => public override bool IsRedundant(ControlPoint existing, double time)
other is EffectControlPoint otherTyped && => !OmitFirstBarLine
KiaiMode == otherTyped.KiaiMode && OmitFirstBarLine == otherTyped.OmitFirstBarLine; && existing is EffectControlPoint existingEffect
&& KiaiMode == existingEffect.KiaiMode
public override bool IsRedundant(ControlPoint existing, double time) => !OmitFirstBarLine && EquivalentTo(existing); && OmitFirstBarLine == existingEffect.OmitFirstBarLine;
} }
} }

View File

@ -68,10 +68,9 @@ namespace osu.Game.Beatmaps.ControlPoints
return newSampleInfo; return newSampleInfo;
} }
public override bool EquivalentTo(ControlPoint other) => public override bool IsRedundant(ControlPoint existing, double time)
other is SampleControlPoint otherTyped && => existing is SampleControlPoint existingSample
SampleBank == otherTyped.SampleBank && SampleVolume == otherTyped.SampleVolume; && SampleBank == existingSample.SampleBank
&& SampleVolume == existingSample.SampleVolume;
public override bool IsRedundant(ControlPoint existing, double time) => EquivalentTo(existing);
} }
} }

View File

@ -48,12 +48,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// </summary> /// </summary>
public double BPM => 60000 / BeatLength; public double BPM => 60000 / BeatLength;
public override bool EquivalentTo(ControlPoint other) => // Timing points are never redundant as they can change the time signature.
other is TimingControlPoint otherTyped public override bool IsRedundant(ControlPoint existing, double time) => false;
&& TimeSignature == otherTyped.TimeSignature && BeatLength.Equals(otherTyped.BeatLength);
public override bool IsRedundant(ControlPoint existing, double time) =>
EquivalentTo(existing)
&& existing.Time == time;
} }
} }

View File

@ -174,9 +174,10 @@ namespace osu.Game.Beatmaps.Formats
return baseInfo; return baseInfo;
} }
public override bool EquivalentTo(ControlPoint other) => public override bool IsRedundant(ControlPoint existing, double time)
base.EquivalentTo(other) && other is LegacySampleControlPoint otherTyped && => base.IsRedundant(existing, time)
CustomSampleBank == otherTyped.CustomSampleBank; && existing is LegacySampleControlPoint existingSample
&& CustomSampleBank == existingSample.CustomSampleBank;
} }
} }
} }

View File

@ -103,7 +103,7 @@ namespace osu.Game.Graphics.Containers
TimeSinceLastBeat = beatLength - TimeUntilNextBeat; TimeSinceLastBeat = beatLength - TimeUntilNextBeat;
if (timingPoint.Equals(lastTimingPoint) && beatIndex == lastBeat) if (timingPoint == lastTimingPoint && beatIndex == lastBeat)
return; return;
using (BeginDelayedSequence(-TimeSinceLastBeat, true)) using (BeginDelayedSequence(-TimeSinceLastBeat, true))