QcSprintLatch Class
Whether the player sprints, from the keys, as in the model (decision E-280): a press of the sprint key while moving forward, or a double tap of the forward key, starts a sprint, which then lasts while the forward key stays held, also after the sprint key is released. More...
| Header: | #include <clientcore/player/QcSprintLatch.h> |
Public Functions
| bool | active() const |
| void | forwardPressed(qint64 timestampMs) |
| void | reset() |
| bool | update(bool forwardHeld, bool sprintHeld, bool sneakHeld) |
Static Public Members
| const qint64 | doubleTapMs |
Detailed Description
Releasing forward or sneaking ends it. Taps are taken from the key press events with their time, so a short tap between two frames still counts as the first of a double tap.
Member Function Documentation
bool QcSprintLatch::active() const
Returns whether the player sprints (as of the latest update()).
void QcSprintLatch::forwardPressed(qint64 timestampMs)
A press of the forward key (not an auto-repeat) at timestampMs (any monotonic clock).
void QcSprintLatch::reset()
Forgets the sprint and earlier taps: a screen opened, the player died or the window lost the focus, so a tap before and one after do not make a double tap.
bool QcSprintLatch::update(bool forwardHeld, bool sprintHeld, bool sneakHeld)
Once per frame with the held keys (forwardHeld, sprintHeld, sneakHeld); returns whether to sprint.
Member Variable Documentation
const qint64 QcSprintLatch::doubleTapMs
Two presses of the forward key at most this far apart start a sprint.