lightyear_inputs_leafwing/
lib.rs

1//! Module to handle inputs that are defined using the `leafwing_input_manager` crate
2//!
3//! ### Adding leafwing inputs
4//!
5//! You first need to create Inputs that are defined using the [`leafwing_input_manager`](https://github.com/Leafwing-Studios/leafwing-input-manager) crate.
6//! (see the documentation of the crate for more information)
7//! In particular your inputs should implement the [`Actionlike`](leafwing_input_manager::Actionlike) trait.
8//!
9//! ```rust
10//! # use bevy_app::App;
11//! # use bevy_reflect::Reflect;
12//! # use serde::{Deserialize, Serialize};
13//! use leafwing_input_manager::Actionlike;
14//! use lightyear_inputs_leafwing::prelude::InputPlugin;
15//!
16//! #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy, Hash, Reflect, Actionlike)]
17//! pub enum PlayerActions {
18//!     Up,
19//!     Down,
20//!     Left,
21//!     Right,
22//! }
23//!
24//! let mut app = App::new();
25//! app.add_plugins(InputPlugin::<PlayerActions>::default());
26//! ```
27//!
28//! ### Usage
29//!
30//! The networking of inputs is completely handled for you. You just need to add the `InputPlugin` to your app.
31//! Make sure that all your systems that depend on user inputs are added to the [`FixedUpdate`] [`Schedule`].
32//!
33//! Currently, global inputs (that are stored in a [`Resource`] instead of being attached to a specific [`Entity`] are not supported)
34//!
35//! [`FixedUpdate`]: bevy_app::prelude::FixedUpdate
36//! [`Resource`]: bevy_ecs::prelude::Resource
37//! [`Entity`]: bevy_ecs::prelude::Entity
38//! [`Schedule`]: bevy_ecs::prelude::Schedule
39#![no_std]
40
41extern crate alloc;
42extern crate core;
43#[cfg(feature = "std")]
44extern crate std;
45
46pub(crate) mod action_diff;
47
48mod action_state;
49
50mod input_message;
51
52mod plugin;
53
54pub mod prelude {
55    pub use crate::input_message::{LeafwingBuffer, LeafwingSnapshot};
56    pub use crate::plugin::InputPlugin;
57}