2021-06-21 21:30:04 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-06-21 21:30:04 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Rulesets.Edit.Checks.Components;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Checks
|
|
|
|
{
|
|
|
|
public class CheckLowDiffOverlaps : ICheck
|
|
|
|
{
|
|
|
|
// For the lowest difficulties, the osu! Ranking Criteria encourages overlapping ~180 BPM 1/2, but discourages ~180 BPM 1/1.
|
|
|
|
private const double should_overlap_threshold = 150; // 200 BPM 1/2
|
|
|
|
private const double should_probably_overlap_threshold = 175; // 170 BPM 1/2
|
|
|
|
private const double should_not_overlap_threshold = 250; // 120 BPM 1/2 = 240 BPM 1/1
|
|
|
|
|
2021-06-22 14:16:19 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Objects need to overlap this much before being treated as an overlap, else it may just be the borders slightly touching.
|
|
|
|
/// </summary>
|
2021-06-21 21:30:04 +08:00
|
|
|
private const double overlap_leniency = 5;
|
|
|
|
|
|
|
|
public CheckMetadata Metadata { get; } = new CheckMetadata(CheckCategory.Spread, "Missing or unexpected overlaps");
|
|
|
|
|
|
|
|
public IEnumerable<IssueTemplate> PossibleTemplates => new IssueTemplate[]
|
|
|
|
{
|
|
|
|
new IssueTemplateShouldOverlap(this),
|
|
|
|
new IssueTemplateShouldProbablyOverlap(this),
|
|
|
|
new IssueTemplateShouldNotOverlap(this)
|
|
|
|
};
|
|
|
|
|
|
|
|
public IEnumerable<Issue> Run(BeatmapVerifierContext context)
|
|
|
|
{
|
|
|
|
// TODO: This should also apply to *lowest difficulty* Normals - they are skipped for now.
|
|
|
|
if (context.InterpretedDifficulty > DifficultyRating.Easy)
|
|
|
|
yield break;
|
|
|
|
|
|
|
|
var hitObjects = context.Beatmap.HitObjects;
|
|
|
|
|
|
|
|
for (int i = 0; i < hitObjects.Count - 1; ++i)
|
|
|
|
{
|
|
|
|
if (!(hitObjects[i] is OsuHitObject hitObject) || hitObject is Spinner)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!(hitObjects[i + 1] is OsuHitObject nextHitObject) || nextHitObject is Spinner)
|
|
|
|
continue;
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
double deltaTime = nextHitObject.StartTime - hitObject.GetEndTime();
|
2021-06-21 21:30:04 +08:00
|
|
|
if (deltaTime >= hitObject.TimeFadeIn + hitObject.TimePreempt)
|
|
|
|
// The objects are not visible at the same time (without mods), hence skipping.
|
|
|
|
continue;
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
float distanceSq = (hitObject.StackedEndPosition - nextHitObject.StackedPosition).LengthSquared;
|
|
|
|
double diameter = (hitObject.Radius - overlap_leniency) * 2;
|
|
|
|
double diameterSq = diameter * diameter;
|
2021-06-21 21:30:04 +08:00
|
|
|
|
|
|
|
bool areOverlapping = distanceSq < diameterSq;
|
|
|
|
|
|
|
|
// Slider ends do not need to be overlapped because of slider leniency.
|
|
|
|
if (!areOverlapping && !(hitObject is Slider))
|
|
|
|
{
|
|
|
|
if (deltaTime < should_overlap_threshold)
|
|
|
|
yield return new IssueTemplateShouldOverlap(this).Create(deltaTime, hitObject, nextHitObject);
|
|
|
|
else if (deltaTime < should_probably_overlap_threshold)
|
|
|
|
yield return new IssueTemplateShouldProbablyOverlap(this).Create(deltaTime, hitObject, nextHitObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (areOverlapping && deltaTime > should_not_overlap_threshold)
|
|
|
|
yield return new IssueTemplateShouldNotOverlap(this).Create(deltaTime, hitObject, nextHitObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract class IssueTemplateOverlap : IssueTemplate
|
|
|
|
{
|
|
|
|
protected IssueTemplateOverlap(ICheck check, IssueType issueType, string unformattedMessage)
|
|
|
|
: base(check, issueType, unformattedMessage)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Issue Create(double deltaTime, params HitObject[] hitObjects) => new Issue(hitObjects, this, deltaTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
public class IssueTemplateShouldOverlap : IssueTemplateOverlap
|
|
|
|
{
|
|
|
|
public IssueTemplateShouldOverlap(ICheck check)
|
|
|
|
: base(check, IssueType.Problem, "These are {0} ms apart and so should be overlapping.")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class IssueTemplateShouldProbablyOverlap : IssueTemplateOverlap
|
|
|
|
{
|
|
|
|
public IssueTemplateShouldProbablyOverlap(ICheck check)
|
|
|
|
: base(check, IssueType.Warning, "These are {0} ms apart and so should probably be overlapping.")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class IssueTemplateShouldNotOverlap : IssueTemplateOverlap
|
|
|
|
{
|
|
|
|
public IssueTemplateShouldNotOverlap(ICheck check)
|
|
|
|
: base(check, IssueType.Problem, "These are {0} ms apart and so should NOT be overlapping.")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|