leafwing_input_manager::action_state

Struct ActionState

source
pub struct ActionState<A: Actionlike> { /* private fields */ }
Expand description

Stores the canonical input-method-agnostic representation of the inputs received

Can be used as either a resource or as a Component on entities that you wish to control directly from player input.

§Disabling actions

Actions can be disabled in four different ways, with increasing granularity:

  1. By disabling updates to all actions using a run condition on InputManagerSystem::Update.
  2. By disabling updates to all actions of type A using a run condition on TickActionStateSystem::<A>.
  3. By setting a specific action state to disabled using ActionState::disable.
  4. By disabling a specific action using ActionState::disable_action.

More general mechanisms of disabling actions will cause specific mechanisms to be ignored. For example, if an entire action state is disabled, then enabling or disabling individual actions will have no effect.

Actions that are disabled will report as released (but not just released), and their values will be zero. Under the hood, their values are still updated to avoid surprising behavior when re-enabled, but they are not reported to the user using standard methods like ActionState::pressed. To check the underlying values, access their ActionData directly.

§Example

use bevy::reflect::Reflect;
use leafwing_input_manager::prelude::*;
use bevy::utils::Instant;

#[derive(Actionlike, PartialEq, Eq, Hash, Clone, Copy, Debug, Reflect)]
enum Action {
    Left,
    Right,
    Jump,
}

let mut action_state = ActionState::<Action>::default();

// Typically, this is done automatically by the `InputManagerPlugin` from user inputs
// using the `ActionState::update` method
action_state.press(&Action::Jump);

assert!(action_state.pressed(&Action::Jump));
assert!(action_state.just_pressed(&Action::Jump));
assert!(action_state.released(&Action::Left));

// Resets just_pressed and just_released
let t0 = Instant::now();
let t1 = Instant::now();

 action_state.tick(t1, t0);
assert!(action_state.pressed(&Action::Jump));
assert!(!action_state.just_pressed(&Action::Jump));

action_state.release(&Action::Jump);
assert!(!action_state.pressed(&Action::Jump));
assert!(action_state.released(&Action::Jump));
assert!(action_state.just_released(&Action::Jump));

let t2 = Instant::now();
action_state.tick(t2, t1);
assert!(action_state.released(&Action::Jump));
assert!(!action_state.just_released(&Action::Jump));

Implementations§

source§

impl<A: Actionlike> ActionState<A>

source

pub fn all_action_data(&self) -> &HashMap<A, ActionData>

Returns a reference to the complete ActionData for all actions.

source

pub fn update(&mut self, updated_actions: UpdatedActions<A>)

Updates the ActionState based on the provided UpdatedActions.

The action_data is typically constructed from InputMap::process_actions, which reads from the assorted ButtonInput resources.

Actions that are disabled will still be updated: instead, their values will be read as released / zero. You can see their underlying values by checking their ActionData directly.

source

pub fn tick(&mut self, _current_instant: Instant, _previous_instant: Instant)

Advances the time for all actions, transitioning them from just_pressed to pressed, and just_released to released.

If the timing feature flag is enabled, the underlying timing and action data will be advanced according to the current_instant.

  • if no Instant is set, the current_instant will be set as the initial time at which the button was pressed / released
  • the Duration will advance to reflect elapsed time
§Example
use bevy::prelude::Reflect;
use leafwing_input_manager::prelude::*;
use leafwing_input_manager::buttonlike::ButtonState;
use bevy::utils::Instant;

#[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
enum Action {
    Run,
    Jump,
}

let mut action_state = ActionState::<Action>::default();

// Actions start released
assert!(action_state.released(&Action::Jump));
assert!(!action_state.just_released(&Action::Run));

// Ticking time moves causes buttons just released to no longer be just released
let t0 = Instant::now();
let t1 = Instant::now();

action_state.tick(t1, t0);
assert!(action_state.released(&Action::Jump));
assert!(!action_state.just_released(&Action::Jump));

action_state.press(&Action::Jump);
assert!(action_state.just_pressed(&Action::Jump));

// Ticking time moves causes buttons just pressed to no longer be just pressed
let t2 = Instant::now();

action_state.tick(t2, t1);
assert!(action_state.pressed(&Action::Jump));
assert!(!action_state.just_pressed(&Action::Jump));
source

pub fn action_data(&self, action: &A) -> Option<&ActionData>

A reference to the ActionData corresponding to the action.

source

pub fn action_data_mut(&mut self, action: &A) -> Option<&mut ActionData>

A mutable reference to the ActionData corresponding to the action.

To initialize the ActionData if it has not yet been triggered, use action_data_mut_or_default method.

source

pub fn action_data_mut_or_default(&mut self, action: &A) -> &mut ActionData

A mutable reference to the ActionData corresponding to the action, initializing it if needed.

If the action has no data yet (because the action has not been triggered), this method will create and insert a default ActionData for you, avoiding potential errors from unwrapping None.

source

pub fn button_data(&self, action: &A) -> Option<&ButtonData>

A reference of the ButtonData corresponding to the action.

Generally, it’ll be clearer to call pressed or so on directly on the ActionState. However, accessing the raw data directly allows you to examine detailed metadata holistically.

§Caution

To access the ButtonData regardless of whether the action has been triggered, use unwrap_or_default on the returned Option.

§Returns
  • Some(ButtonData) if it exists.
  • None if the action has never been triggered (pressed, clicked, etc.).
source

pub fn button_data_mut(&mut self, action: &A) -> Option<&mut ButtonData>

A mutable reference of the ButtonData corresponding to the action.

Generally, it’ll be clearer to call pressed or so on directly on the ActionState. However, accessing the raw data directly allows you to examine detailed metadata holistically.

§Caution

To access the ButtonData regardless of whether the action has been triggered, use unwrap_or_default on the returned Option.

To insert a default ButtonData if it doesn’t exist, use button_data_mut_or_default method.

§Returns
  • Some(ButtonData) if it exists.
  • None if the action has never been triggered (pressed, clicked, etc.).
source

pub fn button_data_mut_or_default(&mut self, action: &A) -> &mut ButtonData

A mutable reference of the ButtonData corresponding to the action, initializing it if needed.

If the action has no data yet (because the action has not been triggered), this method will create and insert a default ButtonData for you, avoiding potential errors from unwrapping None.

Generally, it’ll be clearer to call pressed or so on directly on the ActionState. However, accessing the raw data directly allows you to examine detailed metadata holistically.

source

pub fn axis_data(&self, action: &A) -> Option<&AxisData>

A reference of the AxisData corresponding to the action.

§Caution

To access the AxisData regardless of whether the action has been triggered, use unwrap_or_default on the returned Option.

§Returns
  • Some(AxisData) if it exists.
  • None if the action has never been triggered (pressed, clicked, etc.).
source

pub fn axis_data_mut(&mut self, action: &A) -> Option<&mut AxisData>

A mutable reference of the AxisData corresponding to the action.

§Caution

To insert a default AxisData if it doesn’t exist, use axis_data_mut_or_default method.

§Returns
  • Some(AxisData) if it exists.
  • None if the action has never been triggered (pressed, clicked, etc.).
source

pub fn axis_data_mut_or_default(&mut self, action: &A) -> &mut AxisData

A mutable reference of the AxisData corresponding to the action, initializing it if needed..

If the action has no data yet (because the action has not been triggered), this method will create and insert a default AxisData for you, avoiding potential errors from unwrapping None.

Generally, it’ll be clearer to call pressed or so on directly on the ActionState. However, accessing the raw data directly allows you to examine detailed metadata holistically.

source

pub fn dual_axis_data(&self, action: &A) -> Option<&DualAxisData>

A reference of the DualAxisData corresponding to the action.

§Caution

To access the DualAxisData regardless of whether the action has been triggered, use unwrap_or_default on the returned Option.

§Returns
  • Some(DualAxisData) if it exists.
  • None if the action has never been triggered (pressed, clicked, etc.).
source

pub fn dual_axis_data_mut(&mut self, action: &A) -> Option<&mut DualAxisData>

A mutable reference of the DualAxisData corresponding to the action.

§Caution

To insert a default DualAxisData if it doesn’t exist, use dual_axis_data_mut_or_default method.

§Returns
  • Some(DualAxisData) if it exists.
  • None if the action has never been triggered (pressed, clicked, etc.).
source

pub fn dual_axis_data_mut_or_default(&mut self, action: &A) -> &mut DualAxisData

A mutable reference of the DualAxisData corresponding to the action initializing it if needed.

If the action has no data yet (because the action has not been triggered), this method will create and insert a default DualAxisData for you, avoiding potential errors from unwrapping None.

Generally, it’ll be clearer to call pressed or so on directly on the ActionState. However, accessing the raw data directly allows you to examine detailed metadata holistically.

source

pub fn triple_axis_data(&self, action: &A) -> Option<&TripleAxisData>

A reference of the TripleAxisData corresponding to the action.

§Caution

To access the TripleAxisData regardless of whether the action has been triggered, use unwrap_or_default on the returned Option.

§Returns
  • Some(TripleAxisData) if it exists.
  • None if the action has never been triggered (pressed, clicked, etc.).
source

pub fn triple_axis_data_mut( &mut self, action: &A, ) -> Option<&mut TripleAxisData>

A mutable reference of the TripleAxisData corresponding to the action.

§Caution

To insert a default TripleAxisData if it doesn’t exist, use triple_axis_data_mut_or_default method.

§Returns
  • Some(ButtonData) if it exists.
  • None if the action has never been triggered (pressed, clicked, etc.).
source

pub fn triple_axis_data_mut_or_default( &mut self, action: &A, ) -> &mut TripleAxisData

A mutable reference of the TripleAxisData corresponding to the action initializing it if needed.

If the action has no data yet (because the action has not been triggered), this method will create and insert a default TripleAxisData for you, avoiding potential errors from unwrapping None.

Generally, it’ll be clearer to call pressed or so on directly on the ActionState. However, accessing the raw data directly allows you to examine detailed metadata holistically.

source

pub fn value(&self, action: &A) -> f32

Get the value associated with the corresponding action if present.

Different kinds of bindings have different ways of calculating the value:

  • Binary buttons will have a value of 0.0 when the button is not pressed, and a value of 1.0 when the button is pressed.
  • Some axes, such as an analog stick, will have a value in the range [-1.0, 1.0].
  • Some axes, such as a variable trigger, will have a value in the range [0.0, 1.0].
  • Some buttons will also return a value in the range [0.0, 1.0], such as analog gamepad triggers which may be tracked as buttons or axes. Examples of these include the Xbox LT/Rtriggers and the Playstation L2/R2 triggers. See also the axis_inputs example in the repository.
  • Dual axis inputs will return the magnitude of its Vec2 and will be in the range 0.0..=1.0.
  • Chord inputs will return the value of its first input.

If multiple inputs trigger the same game action at the same time, the value of each triggering input will be added together.

§Warnings

This value will be 0. if the action has never been pressed or released.

This value may not be bounded as you might expect. Consider clamping this to account for multiple triggering inputs, typically using the clamped_value method instead.

source

pub fn set_value(&mut self, action: &A, value: f32)

Sets the value of the action to the provided value.

source

pub fn clamped_value(&self, action: &A) -> f32

Get the value associated with the corresponding action, clamped to [-1.0, 1.0].

§Warning

This value will be 0. by default, even if the action is not an axislike action.

source

pub fn axis_pair(&self, action: &A) -> Vec2

Get the Vec2 from the binding that triggered the corresponding action.

Only events that represent dual-axis control provide a Vec2, and this will return None for other events.

If multiple inputs with an axis pair trigger the same game action at the same time, the value of each axis pair will be added together.

§Warning

This value will be Vec2::ZERO by default, even if the action is not a dual-axislike action.

These values may not be bounded as you might expect. Consider clamping this to account for multiple triggering inputs, typically using the clamped_axis_pair method instead.

source

pub fn set_axis_pair(&mut self, action: &A, pair: Vec2)

Sets the Vec2 of the action to the provided pair.

source

pub fn clamped_axis_pair(&self, action: &A) -> Vec2

Get the Vec2 associated with the corresponding action, clamped to [-1.0, 1.0].

§Warning

This value will be Vec2::ZERO by default, even if the action is not a dual-axislike action.

source

pub fn axis_triple(&self, action: &A) -> Vec3

Get the Vec3 from the binding that triggered the corresponding action.

Only events that represent triple-axis control provide a Vec3, and this will return None for other events.

If multiple inputs with an axis triple trigger the same game action at the same time, the value of each axis triple will be added together.

§Warning

This value will be Vec3::ZERO by default, even if the action is not a triple-axislike action.

These values may not be bounded as you might expect. Consider clamping this to account for multiple triggering inputs, typically using the clamped_axis_triple method instead.

source

pub fn set_axis_triple(&mut self, action: &A, triple: Vec3)

Sets the Vec2 of the action to the provided pair.

source

pub fn clamped_axis_triple(&self, action: &A) -> Vec3

Get the Vec3 associated with the corresponding action, clamped to the cube of values bounded by -1 and 1 on all axes.

§Warning

This value will be Vec3::ZERO by default, even if the action is not a dual-axislike action.

source

pub fn set_button_data(&mut self, action: A, data: ButtonData)

Manually sets the ButtonData of the corresponding action

You should almost always use more direct methods, as they are simpler and less error-prone.

However, this method can be useful for testing, or when transferring ButtonData between action states.

§Example
use bevy::prelude::Reflect;
use leafwing_input_manager::prelude::*;

#[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
enum AbilitySlot {
    Slot1,
    Slot2,
}

#[derive(Actionlike, Clone, Copy, PartialEq, Eq, Hash, Debug, Reflect)]
enum Action {
    Run,
    Jump,
}

let mut ability_slot_state = ActionState::<AbilitySlot>::default();
let mut action_state = ActionState::<Action>::default();

// Extract the state from the ability slot
let slot_1_state = ability_slot_state.button_data(&AbilitySlot::Slot1);

// And transfer it to the actual ability that we care about
// without losing timing information
if let Some(state) = slot_1_state {
   action_state.set_button_data(Action::Run, state.clone());
}
source

pub fn press(&mut self, action: &A)

Press the action

No initial instant or reasons why the button was pressed will be recorded. Instead, this is set through ActionState::tick()

source

pub fn release(&mut self, action: &A)

Release the action

No initial instant will be recorded. Instead, this is set through ActionState::tick()

source

pub fn reset(&mut self, action: &A)

Resets an action to its default state.

Buttons will be released, and axes will be set to 0.

source

pub fn reset_all(&mut self)

Releases all Buttonlike actions, sets all Axislike actions to 0, sets all DualAxislike actions to Vec2::ZERO, and sets all TripleAxislike actions to Vec3::ZERO.

source

pub fn disabled(&self) -> bool

Is the entire ActionState currently disabled?

source

pub fn action_disabled(&self, action: &A) -> bool

Is this action currently disabled?

source

pub fn disable(&mut self)

Disables the entire ActionState.

All values will be reset to their default state.

source

pub fn disable_action(&mut self, action: &A)

Disables the action.

The action’s value will be reset to its default state.

source

pub fn disable_all_actions(&mut self)

Disables all actions

source

pub fn enable(&mut self)

Enables the entire ActionState

source

pub fn enable_action(&mut self, action: &A)

Enables the action

source

pub fn enable_all_actions(&mut self)

Enables all actions

source

pub fn pressed(&self, action: &A) -> bool

Is this action currently pressed?

§Warning

This value will be false by default, even if the action is not a buttonlike action.

source

pub fn just_pressed(&self, action: &A) -> bool

Was this action pressed since the last time tick was called?

§Warning

This value will be false by default, even if the action is not a buttonlike action.

source

pub fn released(&self, action: &A) -> bool

Is this action currently released?

This is always the logical negation of pressed

§Warning

This value will be true by default, even if the action is not a buttonlike action.

source

pub fn just_released(&self, action: &A) -> bool

Was this action released since the last time tick was called?

§Warning

This value will be false by default, even if the action is not a buttonlike action.

source

pub fn get_pressed(&self) -> Vec<A>

Which actions are currently pressed?

source

pub fn get_just_pressed(&self) -> Vec<A>

Which actions were just pressed?

source

pub fn get_released(&self) -> Vec<A>

Which actions are currently released?

source

pub fn get_just_released(&self) -> Vec<A>

Which actions were just released?

source

pub fn instant_started(&self, action: &A) -> Option<Instant>

The Instant that the action was last pressed or released

If the action was pressed or released since the last time ActionState::tick was called the value will be None. This ensures that all our actions are assigned a timing and duration that corresponds exactly to the start of a frame, rather than relying on idiosyncratic timing.

This will also be None if the action was never pressed or released.

source

pub fn current_duration(&self, action: &A) -> Duration

The Duration for which the action has been held or released

This will be Duration::ZERO if the action was never pressed or released.

source

pub fn previous_duration(&self, action: &A) -> Duration

The Duration for which the action was last held or released

This is a snapshot of the ActionState::current_duration state at the time the action was last pressed or released.

This will be Duration::ZERO if the action was never pressed or released.

source

pub fn apply_diff(&mut self, action_diff: &ActionDiff<A>)

Applies an ActionDiff (usually received over the network) to the ActionState.

This lets you reconstruct an ActionState from a stream of ActionDiffs

source

pub fn keys(&self) -> Vec<A>

Returns an owned list of the Actionlike keys in this ActionState.

Trait Implementations§

source§

impl<A: Clone + Actionlike> Clone for ActionState<A>

source§

fn clone(&self) -> ActionState<A>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<A: Actionlike> Component for ActionState<A>
where Self: Send + Sync + 'static,

source§

const STORAGE_TYPE: StorageType = bevy::ecs::component::StorageType::Table

A constant indicating the storage type used for this component.
source§

fn register_component_hooks(_hooks: &mut ComponentHooks)

Called when registering this component, allowing mutable access to its ComponentHooks.
source§

impl<A: Debug + Actionlike> Debug for ActionState<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<A: Actionlike> Default for ActionState<A>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, A> Deserialize<'de> for ActionState<A>
where A: Deserialize<'de> + Actionlike,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<A> FromReflect for ActionState<A>
where Self: Any + Send + Sync, A: TypePath + Actionlike, bool: FromReflect + TypePath + RegisterForReflection, HashMap<A, ActionData>: FromReflect + TypePath + RegisterForReflection,

source§

fn from_reflect(reflect: &dyn Reflect) -> Option<Self>

Constructs a concrete instance of Self from a reflected value.
source§

fn take_from_reflect( reflect: Box<dyn Reflect>, ) -> Result<Self, Box<dyn Reflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
source§

impl<A> GetTypeRegistration for ActionState<A>
where Self: Any + Send + Sync, A: TypePath + Actionlike, bool: FromReflect + TypePath + RegisterForReflection, HashMap<A, ActionData>: FromReflect + TypePath + RegisterForReflection,

source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
source§

impl<A: PartialEq + Actionlike> PartialEq for ActionState<A>

source§

fn eq(&self, other: &ActionState<A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A> Reflect for ActionState<A>
where Self: Any + Send + Sync, A: TypePath + Actionlike, bool: FromReflect + TypePath + RegisterForReflection, HashMap<A, ActionData>: FromReflect + TypePath + RegisterForReflection,

source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
source§

fn into_any(self: Box<Self>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>.
source§

fn as_any(&self) -> &dyn Any

Returns the value as a &dyn Any.
source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns the value as a &mut dyn Any.
source§

fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>

Casts this type to a boxed reflected value.
source§

fn as_reflect(&self) -> &dyn Reflect

Casts this type to a reflected value.
source§

fn as_reflect_mut(&mut self) -> &mut dyn Reflect

Casts this type to a mutable reflected value.
source§

fn clone_value(&self) -> Box<dyn Reflect>

Clones the value as a Reflect trait object. Read more
source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
source§

fn try_apply(&mut self, value: &dyn Reflect) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
source§

fn reflect_owned(self: Box<Self>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
source§

fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>

Returns a “partial equality” comparison result. Read more
source§

fn apply(&mut self, value: &(dyn Reflect + 'static))

Applies a reflected value to this value. Read more
source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
source§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
source§

fn serializable(&self) -> Option<Serializable<'_>>

Returns a serializable version of the value. Read more
source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
source§

impl<A> Serialize for ActionState<A>
where A: Serialize + Actionlike,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<A> Struct for ActionState<A>
where Self: Any + Send + Sync, A: TypePath + Actionlike, bool: FromReflect + TypePath + RegisterForReflection, HashMap<A, ActionData>: FromReflect + TypePath + RegisterForReflection,

source§

fn field(&self, name: &str) -> Option<&dyn Reflect>

Returns a reference to the value of the field named name as a &dyn Reflect.
source§

fn field_mut(&mut self, name: &str) -> Option<&mut dyn Reflect>

Returns a mutable reference to the value of the field named name as a &mut dyn Reflect.
source§

fn field_at(&self, index: usize) -> Option<&dyn Reflect>

Returns a reference to the value of the field with index index as a &dyn Reflect.
source§

fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>

Returns a mutable reference to the value of the field with index index as a &mut dyn Reflect.
source§

fn name_at(&self, index: usize) -> Option<&str>

Returns the name of the field with index index.
source§

fn field_len(&self) -> usize

Returns the number of fields in the struct.
source§

fn iter_fields(&self) -> FieldIter<'_>

Returns an iterator over the values of the reflectable fields for this struct.
source§

fn clone_dynamic(&self) -> DynamicStruct

Clones the struct into a DynamicStruct.
source§

impl<A> TypePath for ActionState<A>
where Self: Any + Send + Sync, A: TypePath + Actionlike,

source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
source§

impl<A> Typed for ActionState<A>
where Self: Any + Send + Sync, A: TypePath + Actionlike, bool: FromReflect + TypePath + RegisterForReflection, HashMap<A, ActionData>: FromReflect + TypePath + RegisterForReflection,

source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
source§

impl<A: Actionlike> Resource for ActionState<A>
where Self: Send + Sync + 'static,

source§

impl<A: Actionlike> StructuralPartialEq for ActionState<A>

Auto Trait Implementations§

§

impl<A> Freeze for ActionState<A>

§

impl<A> RefUnwindSafe for ActionState<A>
where A: RefUnwindSafe,

§

impl<A> Send for ActionState<A>

§

impl<A> Sync for ActionState<A>

§

impl<A> Unpin for ActionState<A>
where A: Unpin,

§

impl<A> UnwindSafe for ActionState<A>
where A: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<C> Bundle for C
where C: Component,

source§

fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId), )

source§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>,

source§

fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )

Gets this Bundle’s component ids. This will be None if the component has not been registered.
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &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)

Convert &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> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<C> DynamicBundle for C
where C: Component,

source§

fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))

source§

impl<T> DynamicTypePath for T
where T: TypePath,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromWorld for T
where T: Default,

source§

fn from_world(_world: &mut World) -> T

Creates Self using data from the given World.
source§

impl<S> GetField for S
where S: Struct,

source§

fn get_field<T>(&self, name: &str) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field named name, downcast to T.
source§

fn get_field_mut<T>(&mut self, name: &str) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field named name, downcast to T.
source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn Reflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

source§

impl<T> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ConditionalSend for T
where T: Send,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

source§

impl<T> Settings for T
where T: 'static + Send + Sync,

source§

impl<T> WasmNotSend for T
where T: Send,

source§

impl<T> WasmNotSendSync for T

source§

impl<T> WasmNotSync for T
where T: Sync,