Fix time being a part of controlpoint change comparisons

This commit is contained in:
smoogipoo 2018-07-02 13:33:59 +09:00
parent c78bfbfa55
commit b664d3ef81
7 changed files with 22 additions and 19 deletions

View File

@ -14,12 +14,15 @@ public class ControlPoint : IComparable<ControlPoint>, IEquatable<ControlPoint>
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
public virtual bool Equals(ControlPoint other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
/// <summary>
/// Whether this <see cref="ControlPoint"/> provides the same changes to gameplay as another <see cref="ControlPoint"/>.
/// </summary>
/// <param name="other">The <see cref="ControlPoint"/> to compare to.</param>
/// <returns>Whether this <see cref="ControlPoint"/> provides the same changes to gameplay as <paramref name="other"/>.</returns>
public virtual bool ChangeEquals(ControlPoint other) => !ReferenceEquals(null, other);
return Time.Equals(other.Time);
}
public bool Equals(ControlPoint other)
=> ChangeEquals(other)
&& Time.Equals(other.Time);
}
}

View File

@ -18,8 +18,8 @@ public double SpeedMultiplier
private double speedMultiplier = 1;
public override bool Equals(ControlPoint other)
=> base.Equals(other)
public override bool ChangeEquals(ControlPoint other)
=> base.ChangeEquals(other)
&& other is DifficultyControlPoint difficulty
&& SpeedMultiplier.Equals(difficulty.SpeedMultiplier);
}

View File

@ -15,8 +15,8 @@ public class EffectControlPoint : ControlPoint
/// </summary>
public bool OmitFirstBarLine;
public override bool Equals(ControlPoint other)
=> base.Equals(other)
public override bool ChangeEquals(ControlPoint other)
=> base.ChangeEquals(other)
&& other is EffectControlPoint effect
&& KiaiMode.Equals(effect.KiaiMode)
&& OmitFirstBarLine.Equals(effect.OmitFirstBarLine);

View File

@ -43,8 +43,8 @@ public class SampleControlPoint : ControlPoint
Volume = sampleInfo.Volume > 0 ? sampleInfo.Volume : SampleVolume
};
public override bool Equals(ControlPoint other)
=> base.Equals(other)
public override bool ChangeEquals(ControlPoint other)
=> base.ChangeEquals(other)
&& other is SampleControlPoint sample
&& SampleBank.Equals(sample.SampleBank)
&& SampleVolume.Equals(sample.SampleVolume);

View File

@ -24,8 +24,8 @@ public double BeatLength
private double beatLength = 1000;
public override bool Equals(ControlPoint other)
=> base.Equals(other)
public override bool ChangeEquals(ControlPoint other)
=> base.ChangeEquals(other)
&& other is TimingControlPoint timing
&& TimeSignature.Equals(timing.TimeSignature)
&& BeatLength.Equals(timing.BeatLength);

View File

@ -359,7 +359,7 @@ private void handleDifficultyControlPoint(DifficultyControlPoint newPoint)
{
var existing = beatmap.ControlPointInfo.DifficultyPointAt(newPoint.Time);
if (newPoint.Equals(existing))
if (newPoint.ChangeEquals(existing))
return;
beatmap.ControlPointInfo.DifficultyPoints.RemoveAll(x => x.Time == newPoint.Time);
@ -370,7 +370,7 @@ private void handleEffectControlPoint(EffectControlPoint newPoint)
{
var existing = beatmap.ControlPointInfo.EffectPointAt(newPoint.Time);
if (newPoint.Equals(existing))
if (newPoint.ChangeEquals(existing))
return;
beatmap.ControlPointInfo.EffectPoints.Add(newPoint);
@ -380,7 +380,7 @@ private void handleSampleControlPoint(SampleControlPoint newPoint)
{
var existing = beatmap.ControlPointInfo.SamplePointAt(newPoint.Time);
if (newPoint.Equals(existing))
if (newPoint.ChangeEquals(existing))
return;
beatmap.ControlPointInfo.SamplePoints.Add(newPoint);

View File

@ -184,8 +184,8 @@ public override SampleInfo ApplyTo(SampleInfo sampleInfo)
return baseInfo;
}
public override bool Equals(ControlPoint other)
=> base.Equals(other)
public override bool ChangeEquals(ControlPoint other)
=> base.ChangeEquals(other)
&& other is LegacySampleControlPoint legacy
&& CustomSampleBank == legacy.CustomSampleBank;
}