mirror of
https://github.com/ppy/osu
synced 2025-02-03 03:42:15 +00:00
Cover area just outside circle in test
This commit is contained in:
parent
77fd748035
commit
b608764554
@ -71,23 +71,23 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
AddAssert("hit registered", () => hitAreaReceptor.HitAction == OsuAction.LeftButton);
|
AddAssert("hit registered", () => hitAreaReceptor.HitAction == OsuAction.LeftButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[TestCase(0.95f, OsuAction.LeftButton)]
|
||||||
public void TestCircleHitTopLeftEdge()
|
[TestCase(1.05f, null)]
|
||||||
|
public void TestHitsCloseToEdge(float relativeDistanceFromCentre, OsuAction? expectedAction)
|
||||||
{
|
{
|
||||||
AddStep("move mouse to top left circle edge", () =>
|
AddStep("move mouse to top left circle edge", () =>
|
||||||
{
|
{
|
||||||
var drawQuad = hitAreaReceptor.ScreenSpaceDrawQuad;
|
var drawQuad = hitAreaReceptor.ScreenSpaceDrawQuad;
|
||||||
// sqrt(2) / 2 = sin(45deg) = cos(45deg)
|
// sqrt(2) / 2 = sin(45deg) = cos(45deg)
|
||||||
// draw width halved to get radius
|
// draw width halved to get radius
|
||||||
// 0.95f taken for leniency
|
float correction = relativeDistanceFromCentre * (float)Math.Sqrt(2) / 2 * (drawQuad.Width / 2);
|
||||||
float correction = 0.95f * (float)Math.Sqrt(2) / 2 * (drawQuad.Width / 2);
|
|
||||||
var mousePosition = new Vector2(drawQuad.Centre.X - correction, drawQuad.Centre.Y - correction);
|
var mousePosition = new Vector2(drawQuad.Centre.X - correction, drawQuad.Centre.Y - correction);
|
||||||
|
|
||||||
InputManager.MoveMouseTo(mousePosition);
|
InputManager.MoveMouseTo(mousePosition);
|
||||||
});
|
});
|
||||||
scheduleHit();
|
scheduleHit();
|
||||||
|
|
||||||
AddAssert("hit registered", () => hitAreaReceptor.HitAction == OsuAction.LeftButton);
|
AddAssert($"hit {(expectedAction == null ? "not " : string.Empty)}registered", () => hitAreaReceptor.HitAction == expectedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
Loading…
Reference in New Issue
Block a user