1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 18:07:28 +08:00

remove ApplyLegacyInfo method

This commit is contained in:
OliBomby 2023-04-25 12:52:21 +02:00
parent ea1e6e9798
commit 891b87a5ff
4 changed files with 32 additions and 46 deletions

View File

@ -163,14 +163,6 @@ namespace osu.Game.Rulesets.Osu.Objects
TickDistance = generateTicks ? (scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier) : double.PositiveInfinity;
}
protected override void ApplyLegacyInfoToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
{
base.ApplyLegacyInfoToSelf(controlPointInfo, difficulty);
DifficultyControlPoint difficultyControlPoint = controlPointInfo is LegacyControlPointInfo legacyInfo ? legacyInfo.DifficultyPointAt(StartTime) : DifficultyControlPoint.DEFAULT;
SliderVelocity = difficultyControlPoint.SliderVelocity;
}
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
{
base.CreateNestedHitObjects(cancellationToken);

View File

@ -17,6 +17,7 @@ using osu.Game.IO;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Beatmaps.Formats
{
@ -27,6 +28,11 @@ namespace osu.Game.Beatmaps.Formats
/// </summary>
public const int EARLY_VERSION_TIMING_OFFSET = 24;
/// <summary>
/// A small adjustment to the start time of control points to account for rounding/precision errors.
/// </summary>
private const double control_point_leniency = 1;
internal static RulesetStore RulesetStore;
private Beatmap beatmap;
@ -87,12 +93,11 @@ namespace osu.Game.Beatmaps.Formats
foreach (var hitObject in this.beatmap.HitObjects)
{
applyLegacyInfoToHitObject(hitObject);
hitObject.ApplyDefaults(this.beatmap.ControlPointInfo, this.beatmap.Difficulty);
applyLegacyInfoAndDefaults(hitObject);
}
}
private void applyLegacyInfoToHitObject(HitObject hitObject)
private void applyLegacyInfoAndDefaults(HitObject hitObject)
{
var legacyInfo = beatmap.ControlPointInfo as LegacyControlPointInfo;
@ -102,7 +107,30 @@ namespace osu.Game.Beatmaps.Formats
#pragma warning restore 618
hitObject.SetContext(new LegacyContext(legacyDifficultyControlPoint.BpmMultiplier, legacyDifficultyControlPoint.GenerateTicks));
hitObject.ApplyLegacyInfo(beatmap.ControlPointInfo, beatmap.Difficulty);
if (hitObject is IHasSliderVelocity hasSliderVelocity)
hasSliderVelocity.SliderVelocity = difficultyControlPoint.SliderVelocity;
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.Difficulty);
SampleControlPoint sampleControlPoint = legacyInfo != null ? legacyInfo.SamplePointAt(hitObject.GetEndTime() + control_point_leniency) : SampleControlPoint.DEFAULT;
foreach (var hitSampleInfo in hitObject.Samples)
{
sampleControlPoint.ApplyTo(hitSampleInfo);
}
if (hitObject is not IHasRepeats hasRepeats) return;
for (int i = 0; i < hasRepeats.NodeSamples.Count; i++)
{
double time = hitObject.StartTime + i * hasRepeats.Duration / hasRepeats.SpanCount() + control_point_leniency;
sampleControlPoint = legacyInfo != null ? legacyInfo.SamplePointAt(time) : SampleControlPoint.DEFAULT;
foreach (var hitSampleInfo in hasRepeats.NodeSamples[i])
{
sampleControlPoint.ApplyTo(hitSampleInfo);
}
}
}
/// <summary>

View File

@ -158,32 +158,6 @@ namespace osu.Game.Rulesets.Objects
HitWindows?.SetDifficulty(difficulty.OverallDifficulty);
}
/// <summary>
/// Applies legacy information to this HitObject.
/// This method gets called at the end of <see cref="LegacyBeatmapDecoder"/> before applying defaults.
/// </summary>
/// <param name="controlPointInfo">The control points.</param>
/// <param name="difficulty">The difficulty settings to use.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public void ApplyLegacyInfo(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty, CancellationToken cancellationToken = default)
{
var legacyInfo = controlPointInfo as LegacyControlPointInfo;
ApplyLegacyInfoToSelf(controlPointInfo, difficulty);
// This is done here after ApplyLegacyInfoToSelf as we may require custom defaults to be applied to have an accurate end time.
SampleControlPoint sampleControlPoint = legacyInfo != null ? legacyInfo.SamplePointAt(this.GetEndTime() + control_point_leniency) : SampleControlPoint.DEFAULT;
foreach (var hitSampleInfo in Samples)
{
sampleControlPoint.ApplyTo(hitSampleInfo);
}
}
protected virtual void ApplyLegacyInfoToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
{
}
protected virtual void CreateNestedHitObjects(CancellationToken cancellationToken)
{
}

View File

@ -54,14 +54,6 @@ namespace osu.Game.Rulesets.Objects.Legacy
Velocity = scoringDistance / timingPoint.BeatLength;
}
protected override void ApplyLegacyInfoToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
{
base.ApplyLegacyInfoToSelf(controlPointInfo, difficulty);
DifficultyControlPoint difficultyControlPoint = controlPointInfo is LegacyControlPointInfo legacyInfo ? legacyInfo.DifficultyPointAt(StartTime) : DifficultyControlPoint.DEFAULT;
SliderVelocity = difficultyControlPoint.SliderVelocity;
}
public double LegacyLastTickOffset => 36;
}
}