melee stroke
A sword stroke you can cut short or chain. A swing that must play to its
last frame before the next one makes you wait through a follow-through that
does nothing. So a press during a stroke is read by where the stroke is
(progress, 0 to 1), with three tunable marks:
- before
restartBefore(default 0.1): the stroke is cancelled and starts again, so a double press is one swing, not two; - from
chainFrom(default 0.9): a new stroke starts at once; - from
queueFrom(default 0.8) up tochainFrom: a follow-up is queued and starts when the stroke reacheschainFrom; - in between, the press is ignored: the stroke is committed.
Holding the trigger chains too: a held stroke starts the next at chainFrom.
The blow lands once per stroke, when it passes hitAt (default 0.4); a
stroke cancelled before then never lands.
strokeStep(state, input, rules) is the whole clock, pure: the biped feeds
it the trigger and the frame's step, and plays a new stroke when it says
start, deals the blow when it says hit. meleeTargets picks what a blow
reaches: within reach metres and arc degrees of the way the swinger
faces, nearest first.