2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-11-20 15:15:17 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
2023-01-25 14:50:49 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-12-27 16:34:07 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2023-01-25 14:50:49 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2020-11-20 15:15:17 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2017-12-27 16:34:07 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2020-11-20 15:15:17 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2018-01-01 18:55:24 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-11-20 15:15:17 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-27 16:34:07 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
|
{
|
2018-03-02 14:34:31 +08:00
|
|
|
|
[TestFixture]
|
2020-04-07 14:38:29 +08:00
|
|
|
|
public partial class TestSceneHitCircle : OsuSkinnableTestScene
|
2017-12-27 16:34:07 +08:00
|
|
|
|
{
|
2017-12-27 18:47:55 +08:00
|
|
|
|
private int depthIndex;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2023-01-25 14:50:49 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuConfigManager config { get; set; }
|
|
|
|
|
|
2020-10-02 17:18:14 +08:00
|
|
|
|
[Test]
|
2021-06-17 14:08:09 +08:00
|
|
|
|
public void TestHits()
|
2017-12-27 16:34:07 +08:00
|
|
|
|
{
|
2021-06-02 15:04:53 +08:00
|
|
|
|
AddStep("Hit Big Single", () => SetContents(_ => testSingle(2, true)));
|
|
|
|
|
AddStep("Hit Medium Single", () => SetContents(_ => testSingle(5, true)));
|
|
|
|
|
AddStep("Hit Small Single", () => SetContents(_ => testSingle(7, true)));
|
|
|
|
|
AddStep("Hit Big Stream", () => SetContents(_ => testStream(2, true)));
|
|
|
|
|
AddStep("Hit Medium Stream", () => SetContents(_ => testStream(5, true)));
|
|
|
|
|
AddStep("Hit Small Stream", () => SetContents(_ => testStream(7, true)));
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-17 14:06:56 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestHittingEarly()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Hit stream early", () => SetContents(_ => testStream(5, true, -150)));
|
2021-06-17 14:08:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestMisses()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Miss Big Single", () => SetContents(_ => testSingle(2)));
|
|
|
|
|
AddStep("Miss Medium Single", () => SetContents(_ => testSingle(5)));
|
|
|
|
|
AddStep("Miss Small Single", () => SetContents(_ => testSingle(7)));
|
|
|
|
|
AddStep("Miss Big Stream", () => SetContents(_ => testStream(2)));
|
|
|
|
|
AddStep("Miss Medium Stream", () => SetContents(_ => testStream(5)));
|
|
|
|
|
AddStep("Miss Small Stream", () => SetContents(_ => testStream(7)));
|
2021-06-17 14:06:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestHittingLate()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Hit stream late", () => SetContents(_ => testStream(5, true, 150)));
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-25 14:50:49 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestHitLighting()
|
|
|
|
|
{
|
|
|
|
|
AddToggleStep("toggle hit lighting", v => config.SetValue(OsuSetting.HitLighting, v));
|
|
|
|
|
AddStep("Hit Big Single", () => SetContents(_ => testSingle(2, true)));
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-26 18:29:06 +08:00
|
|
|
|
private Drawable testSingle(float circleSize, bool auto = false, double timeOffset = 0, Vector2? positionOffset = null)
|
2020-11-20 15:15:17 +08:00
|
|
|
|
{
|
|
|
|
|
var playfield = new TestOsuPlayfield();
|
2022-09-15 18:17:54 +08:00
|
|
|
|
|
|
|
|
|
for (double t = timeOffset; t < timeOffset + 60000; t += 2000)
|
|
|
|
|
playfield.Add(createSingle(circleSize, auto, t, positionOffset));
|
|
|
|
|
|
2020-11-20 15:15:17 +08:00
|
|
|
|
return playfield;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-17 14:06:56 +08:00
|
|
|
|
private Drawable testStream(float circleSize, bool auto = false, double hitOffset = 0)
|
2020-11-20 15:15:17 +08:00
|
|
|
|
{
|
|
|
|
|
var playfield = new TestOsuPlayfield();
|
|
|
|
|
|
|
|
|
|
Vector2 pos = new Vector2(-250, 0);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= 1000; i += 100)
|
|
|
|
|
{
|
2021-06-17 14:06:56 +08:00
|
|
|
|
playfield.Add(createSingle(circleSize, auto, i, pos, hitOffset));
|
2020-11-20 15:15:17 +08:00
|
|
|
|
pos.X += 50;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return playfield;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-17 14:06:56 +08:00
|
|
|
|
private TestDrawableHitCircle createSingle(float circleSize, bool auto, double timeOffset, Vector2? positionOffset, double hitOffset = 0)
|
2017-12-27 16:34:07 +08:00
|
|
|
|
{
|
2019-11-12 18:35:08 +08:00
|
|
|
|
positionOffset ??= Vector2.Zero;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-27 18:47:55 +08:00
|
|
|
|
var circle = new HitCircle
|
|
|
|
|
{
|
|
|
|
|
StartTime = Time.Current + 1000 + timeOffset,
|
2020-11-20 15:15:17 +08:00
|
|
|
|
Position = OsuPlayfield.BASE_SIZE / 4 + positionOffset.Value,
|
2017-12-27 18:47:55 +08:00
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-12-29 00:06:15 +08:00
|
|
|
|
circle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-17 14:06:56 +08:00
|
|
|
|
var drawable = CreateDrawableHitCircle(circle, auto, hitOffset);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-16 17:46:29 +08:00
|
|
|
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObject>())
|
|
|
|
|
mod.ApplyToDrawableHitObject(drawable);
|
2019-07-26 18:29:06 +08:00
|
|
|
|
return drawable;
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-17 14:06:56 +08:00
|
|
|
|
protected virtual TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto, double hitOffset = 0) => new TestDrawableHitCircle(circle, auto, hitOffset)
|
2019-07-29 16:05:13 +08:00
|
|
|
|
{
|
|
|
|
|
Depth = depthIndex++
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-06 16:38:58 +08:00
|
|
|
|
protected partial class TestDrawableHitCircle : DrawableHitCircle
|
2017-12-29 00:06:15 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly bool auto;
|
2021-06-17 14:06:56 +08:00
|
|
|
|
private readonly double hitOffset;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-17 14:06:56 +08:00
|
|
|
|
public TestDrawableHitCircle(HitCircle h, bool auto, double hitOffset)
|
2019-02-28 12:31:40 +08:00
|
|
|
|
: base(h)
|
2017-12-29 00:06:15 +08:00
|
|
|
|
{
|
|
|
|
|
this.auto = auto;
|
2021-06-17 14:06:56 +08:00
|
|
|
|
this.hitOffset = hitOffset;
|
2017-12-29 00:06:15 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-17 15:13:47 +08:00
|
|
|
|
public void TriggerJudgement() => Schedule(() => UpdateResult(true));
|
2018-07-06 16:38:58 +08:00
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2017-12-29 00:06:15 +08:00
|
|
|
|
{
|
2021-06-17 15:13:47 +08:00
|
|
|
|
if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current) != false)
|
2017-12-29 00:06:15 +08:00
|
|
|
|
{
|
2018-01-01 18:55:24 +08:00
|
|
|
|
// force success
|
2018-08-03 14:38:48 +08:00
|
|
|
|
ApplyResult(r => r.Type = HitResult.Great);
|
2017-12-29 00:06:15 +08:00
|
|
|
|
}
|
2018-01-01 18:55:24 +08:00
|
|
|
|
else
|
2018-08-06 10:31:46 +08:00
|
|
|
|
base.CheckForResult(userTriggered, timeOffset);
|
2017-12-29 00:06:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-20 15:15:17 +08:00
|
|
|
|
|
|
|
|
|
protected partial class TestOsuPlayfield : OsuPlayfield
|
|
|
|
|
{
|
|
|
|
|
public TestOsuPlayfield()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|