1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 21:12:55 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Edit/Blueprints/HitPlacementBlueprint.cs
2022-11-27 00:00:27 +09:00

61 lines
1.6 KiB
C#

// 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.
#nullable disable
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.UI;
using osuTK;
using osuTK.Input;
namespace osu.Game.Rulesets.Taiko.Edit.Blueprints
{
public partial class HitPlacementBlueprint : PlacementBlueprint
{
private readonly HitPiece piece;
public new Hit HitObject => (Hit)base.HitObject;
public HitPlacementBlueprint()
: base(new Hit())
{
InternalChild = piece = new HitPiece
{
Size = new Vector2(TaikoHitObject.DEFAULT_SIZE * TaikoPlayfield.DEFAULT_HEIGHT)
};
}
protected override void LoadComplete()
{
base.LoadComplete();
BeginPlacement();
}
protected override bool OnMouseDown(MouseDownEvent e)
{
switch (e.Button)
{
case MouseButton.Left:
HitObject.Type = HitType.Centre;
EndPlacement(true);
return true;
case MouseButton.Right:
HitObject.Type = HitType.Rim;
EndPlacement(true);
return true;
}
return false;
}
public override void UpdateTimeAndPosition(SnapResult result)
{
piece.Position = ToLocalSpace(result.ScreenSpacePosition);
base.UpdateTimeAndPosition(result);
}
}
}