pub struct TnuaSimpleAirActionsCounter<S: TnuaScheme> { /* private fields */ }Expand description
A simple counter that counts together all the air actions a character is able to perform.
Itโs update must be called every frame, in the same schedule as
TnuaControllerPlugin.
Implementationsยง
Sourceยงimpl<S> TnuaSimpleAirActionsCounter<S>
impl<S> TnuaSimpleAirActionsCounter<S>
Sourcepub fn update(&mut self, controller: &TnuaController<S>)
pub fn update(&mut self, controller: &TnuaController<S>)
Call this every frame, in the same schedule as TnuaControllerPlugin, to track the air
actions.
Sourcepub fn reset_count_to(&mut self, count: usize)
pub fn reset_count_to(&mut self, count: usize)
Resets the air actions counter to a specific count, excluding the current action.
This method allows you to manually set the count of air actions (excluding the current action) to a specified value. Use this when you need to synchronize or initialize the air actions count to a specific state.
ยงArguments
count- The new count to set for air actions, excluding the current action.
ยงExample
// Reset the air actions count to 3 (excluding the current action). should also be updated as stated in TnuaAirActionsTracker
air_actions_counter.reset_count_to(3);Sourcepub fn get_count_mut(&mut self) -> Option<&mut usize>
pub fn get_count_mut(&mut self) -> Option<&mut usize>
Obtain a mutable reference to the air counter.
This can be use to modify the air counter while the player is in the air - for example, restoring an air jump when they pick up a floating token.
When it fits the usage, prefer reset_count which is simpler.
get_count_mut should be used for more complex cases, e.g. when the player is allowed
multiple air jumps, but only one jump gets restored per token.
Note that:
- When the character is grounded, this method returns
None. This is only for mutating the counter while the character is airborne. - When the character jumps from the ground, or starts a free fall, the counter is one - not zero. Setting the counter to 0 will mean that the next air jump will actually be treated as a ground jump - and theyโll get another air jump in addition to it. This is usually not the desired behavior.
- Changing the action counter returned by this method will not affect the value
air_count_forreturns for an action that continues to be fed.
Sourcepub fn reset_count(&mut self)
pub fn reset_count(&mut self)
Resets the air actions counter.
This is equivalent to setting the counter to 1 using:
if let Some(count) = air_actions_counter.get_count_mut() {
*count = 1;
}The reason it is set to 1 and not 0 is that when the character jumps from the ground or
starts a free fall the counter is 1 - and this is what one would usually want to reset to.
Having a counter of 0 means that the character is grounded - but in that case
get_count_mut will return None and the counter will not change.
Sourcepub fn air_count_for(&self, action: S::ActionDiscriminant) -> usize
pub fn air_count_for(&self, action: S::ActionDiscriminant) -> usize
Calculate the โair numberโ of an action.
The air number of a ground action is 0. The first air jump (double jump) as an air number of 1, the second (triple jump) has an air number of 2 and so on. Other air actions (like air dashes) are counted together with the jumps.
Use this number to:
- Determine if the action is allowed.
- Optionally change the actionโs parameters as the air number progresses.
Note that the action discriminant is important, because Tnua relies on constant feed of
some actions. As long as you pass the correct discriminant, the number will not change
while the action continues to be fed. The discriminant can be obtained with
TnuaController::action_discriminant.
Trait Implementationsยง
Sourceยงimpl<S: TnuaScheme> Component for TnuaSimpleAirActionsCounter<S>
impl<S: TnuaScheme> Component for TnuaSimpleAirActionsCounter<S>
Sourceยงconst STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table
Sourceยงtype Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSourceยงfn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Sourceยงfn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Sourceยงfn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSourceยงfn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Sourceยงfn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Sourceยงfn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Sourceยงfn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Sourceยงfn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Sourceยงfn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSourceยงimpl<S: TnuaScheme> Default for TnuaSimpleAirActionsCounter<S>
impl<S: TnuaScheme> Default for TnuaSimpleAirActionsCounter<S>
Auto Trait Implementationsยง
impl<S> Freeze for TnuaSimpleAirActionsCounter<S>
impl<S> RefUnwindSafe for TnuaSimpleAirActionsCounter<S>
impl<S> Send for TnuaSimpleAirActionsCounter<S>
impl<S> Sync for TnuaSimpleAirActionsCounter<S>
impl<S> Unpin for TnuaSimpleAirActionsCounter<S>
impl<S> UnwindSafe for TnuaSimpleAirActionsCounter<S>
Blanket Implementationsยง
Sourceยงimpl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Sourceยงfn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Sourceยงfn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Sourceยงimpl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
Sourceยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Sourceยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Sourceยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Sourceยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Anyโs vtable from &Traitโs.Sourceยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Anyโs vtable from &mut Traitโs.Sourceยงimpl<T> DowncastSend for T
impl<T> DowncastSend for T
Sourceยงimpl<T> DowncastSync for T
impl<T> DowncastSync for T
Sourceยงimpl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Sourceยงunsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Sourceยงunsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Sourceยงimpl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Sourceยงfn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Sourceยงimpl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Sourceยงimpl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more