mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Use redundancy test
This commit is contained in:
@ -25,6 +25,14 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// <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>
|
||||
/// <param name="other">Another control point to compare with.</param>
|
||||
/// <param name="time">The time this timing point will be placed at.</param>
|
||||
/// <returns>Whether redundant.</returns>
|
||||
public abstract bool IsRedundant(ControlPoint other, double time);
|
||||
|
||||
public bool Equals(ControlPoint other) => Time == other?.Time && EquivalentTo(other);
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
break;
|
||||
}
|
||||
|
||||
return existing?.EquivalentTo(newPoint) == true;
|
||||
return newPoint.IsRedundant(existing, time);
|
||||
}
|
||||
|
||||
private void groupItemAdded(ControlPoint controlPoint)
|
||||
|
@ -29,5 +29,6 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
|
||||
public override bool EquivalentTo(ControlPoint other) =>
|
||||
other is DifficultyControlPoint otherTyped && otherTyped.SpeedMultiplier.Equals(SpeedMultiplier);
|
||||
public override bool IsRedundant(ControlPoint other, double time) => EquivalentTo(other);
|
||||
}
|
||||
}
|
||||
|
@ -38,5 +38,6 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
public override bool EquivalentTo(ControlPoint other) =>
|
||||
other is EffectControlPoint otherTyped &&
|
||||
KiaiMode == otherTyped.KiaiMode && OmitFirstBarLine == otherTyped.OmitFirstBarLine;
|
||||
public override bool IsRedundant(ControlPoint other, double time) => !OmitFirstBarLine && EquivalentTo(other);
|
||||
}
|
||||
}
|
||||
|
@ -71,5 +71,6 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
public override bool EquivalentTo(ControlPoint other) =>
|
||||
other is SampleControlPoint otherTyped &&
|
||||
SampleBank == otherTyped.SampleBank && SampleVolume == otherTyped.SampleVolume;
|
||||
public override bool IsRedundant(ControlPoint other, double time) => EquivalentTo(other);
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
|
||||
public override bool EquivalentTo(ControlPoint other) =>
|
||||
other is TimingControlPoint otherTyped
|
||||
&& Time == otherTyped.Time && TimeSignature == otherTyped.TimeSignature && BeatLength.Equals(otherTyped.BeatLength);
|
||||
&& TimeSignature == otherTyped.TimeSignature && BeatLength.Equals(otherTyped.BeatLength);
|
||||
|
||||
public override bool IsRedundant(ControlPoint other, double time) =>
|
||||
EquivalentTo(other)
|
||||
&& other.Time == time;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user