1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 14:47:26 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/CirclePiece.cs

55 lines
1.5 KiB
C#
Raw Normal View History

// 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
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Game.Skinning;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
public class CirclePiece : Container, IKeyBindingHandler<OsuAction>
{
// IsHovered is used
public override bool HandlePositionalInput => true;
2018-04-13 17:19:50 +08:00
public Func<bool> Hit;
2019-01-21 09:57:14 +08:00
public OsuAction? HitAction;
2018-04-13 17:19:50 +08:00
public CirclePiece()
{
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
2018-04-13 17:19:50 +08:00
Masking = true;
CornerRadius = Size.X / 2;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
InternalChild = new SkinnableDrawable("Play/osu/hitcircle", _ => new DefaultCirclePiece());
}
public bool OnPressed(OsuAction action)
{
switch (action)
{
case OsuAction.LeftButton:
case OsuAction.RightButton:
2019-01-21 09:57:14 +08:00
if (IsHovered && (Hit?.Invoke() ?? false))
{
HitAction = action;
return true;
}
break;
2018-04-13 17:19:50 +08:00
}
return false;
}
public bool OnReleased(OsuAction action) => false;
}
}