summaryrefslogtreecommitdiff
path: root/src/SMAPI/SButtonState.cs
blob: 5f3e8d3c8a147144e1e192c997b94dc14eb7a07d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
namespace StardewModdingAPI
{
    /// <summary>The input state for a button during an update frame.</summary>
    public enum SButtonState
    {
        /// <summary>The button was neither pressed, held, nor released.</summary>
        None,

        /// <summary>The button was pressed in this frame.</summary>
        Pressed,

        /// <summary>The button has been held since the last frame.</summary>
        Held,

        /// <summary>The button was released in this frame.</summary>
        Released
    }

    /// <summary>Extension methods for <see cref="SButtonState"/>.</summary>
    public static class InputStatusExtensions
    {
        /// <summary>Whether the button was pressed or held.</summary>
        /// <param name="state">The button state.</param>
        public static bool IsDown(this SButtonState state)
        {
            return state == SButtonState.Held || state == SButtonState.Pressed;
        }
    }
}