Roses/Assets/Scripts/Domain/Input/InputReader.cs
2024-04-14 18:53:13 +02:00

17 lines
No EOL
431 B
C#

namespace Domain.Input {
public abstract class InputReader {
private bool _wasPressed;
private bool _isPressed;
protected abstract int Key { get; }
public void UpdateInput() {
_wasPressed = _isPressed;
_isPressed = Win32API.GetAsyncKeyState(Key) != 0;
}
public bool KeyDown() => _isPressed && !_wasPressed;
public bool KeyPressed() => _isPressed;
public bool KeyUp() => !_isPressed && _wasPressed;
}
}