game_toolkit_platformer/sim/moves.rs
1//! [`Moves`]: which built-in moves may run in one step. An [`Ability`](super::Ability)
2//! clears what its own move rules out in [`Ability::before`](super::Ability::before): no
3//! dash while attacking, no wall grab while carrying, slow walking while pushing.
4
5/// Which built-in moves may run this step, and how fast running may go. Every step starts
6/// from [`Moves::ALL`]; abilities narrow it before the built-in moves run.
7///
8/// A cleared move doesn't start, and one in progress lets go where that makes sense (a
9/// climb without `climb` lets go of the wall, a glide without `glide` folds). Presses
10/// stay buffered as usual, so a jump pressed while `jump` was cleared can still fire once
11/// it is back within the buffer.
12#[derive(Clone, Copy, Debug, PartialEq)]
13pub struct Moves {
14 /// Every jump: from the ground, coyote, roll, wall, climb, in the air; and dropping
15 /// through one-way platforms.
16 pub jump: bool,
17 /// Starting a dash.
18 pub dash: bool,
19 /// Starting a dive.
20 pub dive: bool,
21 /// Grabbing and holding on to walls.
22 pub climb: bool,
23 /// Charging a super dash.
24 pub super_dash: bool,
25 /// Gliding.
26 pub glide: bool,
27 /// The most running (and walking) may reach on its own, units/s: `0.0` keeps the body
28 /// from accelerating at all. Speed from elsewhere (a launch, a dash's end) still
29 /// brakes down to it at the tuning's rate.
30 pub max_run: f32,
31}
32
33impl Moves {
34 /// Everything allowed, running at the tuning's full speed.
35 pub const ALL: Moves = Moves {
36 jump: true,
37 dash: true,
38 dive: true,
39 climb: true,
40 super_dash: true,
41 glide: true,
42 max_run: f32::INFINITY,
43 };
44}
45
46impl Default for Moves {
47 fn default() -> Self {
48 Self::ALL
49 }
50}