feat!: fix some lifetimes in InputContainerInner, almast done one example, add default for plugin, rebase src from crate/bevy_controls to src

This commit is contained in:
2024-02-10 02:42:18 +01:00
parent 5fc1382ceb
commit 608781faf6
19 changed files with 899 additions and 84 deletions
+18 -6
View File
@@ -4,10 +4,20 @@ use bevy_input::{Input, keyboard::KeyCode, mouse::MouseButton};
use crate::{resource::*, contract::{Action, GameState, InputsContainer}};
pub struct ControlsPlugin<Action, InputsContainer, GameState> {
_action: std::marker::PhantomData<Action>,
_inputs_container: std::marker::PhantomData<InputsContainer>,
_game_state: std::marker::PhantomData<GameState>,
pub struct ControlsPlugin<A, Ic, Gs> {
_action: std::marker::PhantomData<A>,
_inputs_container: std::marker::PhantomData<Ic>,
_game_state: std::marker::PhantomData<Gs>,
}
impl<A, Ic, Gs> Default for ControlsPlugin<A, Ic, Gs> {
fn default() -> Self {
Self {
_action: std::marker::PhantomData,
_inputs_container: std::marker::PhantomData,
_game_state: std::marker::PhantomData,
}
}
}
impl<
@@ -17,6 +27,8 @@ impl<
> Plugin for ControlsPlugin<A, Ic, Gs> {
fn build(&self, app: &mut App) {
app.init_resource::<Controls<A, Gs>>()
.init_resource::<Ic>()
.add_state::<Gs>()
.add_systems(Update, Self::save_input);
#[cfg(feature = "reflect")]
@@ -34,7 +46,7 @@ impl<
fn save_input(
keyboard_input: Res<Input<KeyCode>>,
mouse_input: Res<Input<MouseButton>>,
lobby: ResMut<Ic>,
mut lobby: ResMut<Ic>,
controls: Res<Controls<A, Gs>>,
game_state: Res<State<Gs>>,
) {
@@ -235,4 +247,4 @@ impl<
// log::info!("without casting: {:?}", duration);
// }
// }
// }