idanarye / bevy-tnua

A floating character controller for Bevy
https://crates.io/crates/bevy-tnua
Apache License 2.0
238 stars 16 forks source link

Added convenience functions for checking airborne state and resetting the counter for AirActions #32

Closed Microwonk closed 11 months ago

Microwonk commented 11 months ago

Documentation and examples provided, airborne functions are referencing the discussion on #31.

idanarye commented 11 months ago

I'm going to just merge this and do the changes myself.

Regarding reset_count - this is what I'm going to do:

  1. reset_count will set the number to 1 - unless it's already zero, in which case it'll leave it as zero. This is the usual usecase.
  2. Instead of reset_count_to, I'll create a method named get_count_mut which will return a mutable reference to the count. It'll will return an Option<&mut usize>, so if the character is grounded it'll return None and expose the fact that the counter cannot be altered for grounded characters. I'm using this design because I figure that if someone is interested in setting it to something other than what reset_count does - they'll probably want to check the current value (e.g. in order to decrement it by one)
    • This means that someone could still set the value to 0 while the character is in midair, but it'll be harder to do by accident.
  3. The active action will not be affected, because I'll have it store the counter it started with instead of calculating it from the current counter minus 1.