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

Add safety against playfield potentially not being available during mania note placement

This commit is contained in:
Dean Herbert 2022-05-19 15:53:53 +09:00
parent f7e055dbfe
commit 5af7641e94

View File

@ -55,24 +55,25 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
base.UpdateTimeAndPosition(result);
var playfield = (Column)result.Playfield;
if (result.Playfield is Column col)
{
// Apply an offset to better align with the visual grid.
// This should only be applied during placement, as during selection / drag operations the movement is relative
// to the initial point of interaction rather than the grid.
switch (playfield.ScrollingInfo.Direction.Value)
switch (col.ScrollingInfo.Direction.Value)
{
case ScrollingDirection.Down:
result.ScreenSpacePosition -= new Vector2(0, getNoteHeight(playfield) / 2);
result.ScreenSpacePosition -= new Vector2(0, getNoteHeight(col) / 2);
break;
case ScrollingDirection.Up:
result.ScreenSpacePosition += new Vector2(0, getNoteHeight(playfield) / 2);
result.ScreenSpacePosition += new Vector2(0, getNoteHeight(col) / 2);
break;
}
if (PlacementActive == PlacementState.Waiting)
Column = playfield;
Column = col;
}
}
private float getNoteHeight(Column resultPlayfield) =>