1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +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
{
public abstract class ControlPoint : IComparable<ControlPoint>, IEquatable<ControlPoint>
public abstract class ControlPoint : IComparable<ControlPoint>
{
/// <summary>
/// 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);
/// <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>
/// Whether this control point results in a meaningful change when placed after another.
/// </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>
/// <returns>Whether redundant.</returns>
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;
}
public override bool EquivalentTo(ControlPoint other) =>
other is DifficultyControlPoint otherTyped && otherTyped.SpeedMultiplier.Equals(SpeedMultiplier);
public override bool IsRedundant(ControlPoint existing, double time) => EquivalentTo(existing);
public override bool IsRedundant(ControlPoint existing, double time)
=> existing is DifficultyControlPoint existingDifficulty
&& SpeedMultiplier == existingDifficulty.SpeedMultiplier;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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