MoonWorks/src/Input/VirtualButton.cs

35 lines
769 B
C#
Raw Normal View History

2022-03-18 18:46:44 +00:00
namespace MoonWorks.Input
{
2022-07-12 23:09:23 +00:00
public abstract class VirtualButton
2022-03-18 18:46:44 +00:00
{
2022-07-12 23:09:23 +00:00
public ButtonState State { get; protected set; }
2022-03-18 18:46:44 +00:00
/// <summary>
/// True if the button is pressed or held.
/// </summary>
2022-03-18 18:46:44 +00:00
public bool IsDown => State.IsDown;
/// <summary>
/// True if the button has been continuously held for more than one frame.
/// </summary>
2022-03-18 18:46:44 +00:00
public bool IsHeld => State.IsHeld;
/// <summary>
/// True if the button was pressed this exact frame.
/// </summary>
2022-03-18 18:46:44 +00:00
public bool IsPressed => State.IsPressed;
/// <summary>
/// True if the button is not pressed.
/// </summary>
2022-03-18 18:46:44 +00:00
public bool IsReleased => State.IsReleased;
2022-07-12 23:09:23 +00:00
internal virtual void Update()
2022-03-18 18:46:44 +00:00
{
2022-07-12 23:09:23 +00:00
State = State.Update(CheckPressed());
2022-03-18 18:46:44 +00:00
}
2022-07-12 23:09:23 +00:00
internal abstract bool CheckPressed();
2022-03-18 18:46:44 +00:00
}
}