refactor(examples): use bevy_controls_derive::GameState
This commit is contained in:
@@ -7,14 +7,15 @@
|
|||||||
use bevy::{ecs::schedule::States, prelude::*};
|
use bevy::{ecs::schedule::States, prelude::*};
|
||||||
use bevy_controls::{
|
use bevy_controls::{
|
||||||
contract::{
|
contract::{
|
||||||
Action, ActionInner, GameState, GameStateInner, InputsContainer, InputsContainerInner,
|
InputsContainer, InputsContainerInner,
|
||||||
},
|
},
|
||||||
plugin::ControlsPlugin,
|
plugin::ControlsPlugin,
|
||||||
resource::{Binding, ButtonCombination, Controls, InputType, InputValue, PlayerInputs},
|
resource::{Binding, ButtonCombination, Controls, InputType, InputValue, PlayerInputs},
|
||||||
};
|
};
|
||||||
use strum_macros::EnumIter;
|
use strum_macros::EnumIter;
|
||||||
|
use bevy_controls_derive::{Action, GameState};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, EnumIter, Clone, Copy, Debug, bevy_controls_derive::Action)]
|
#[derive(PartialEq, Eq, Hash, EnumIter, Clone, Copy, Debug, Action)]
|
||||||
enum MyAction {
|
enum MyAction {
|
||||||
Forward,
|
Forward,
|
||||||
Back,
|
Back,
|
||||||
@@ -23,16 +24,12 @@ enum MyAction {
|
|||||||
Up,
|
Up,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(States, PartialEq, Eq, Clone, Hash, Debug, Default)]
|
#[derive(States, PartialEq, Eq, Clone, Hash, Debug, Default, GameState)]
|
||||||
enum MyGameState {
|
enum MyGameState {
|
||||||
#[default]
|
#[default]
|
||||||
InGame,
|
InGame,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GameState for MyGameState {}
|
|
||||||
|
|
||||||
impl GameStateInner for MyGameState {}
|
|
||||||
|
|
||||||
#[derive(Resource, Default, Clone, Debug)]
|
#[derive(Resource, Default, Clone, Debug)]
|
||||||
struct MyInputsContainer {
|
struct MyInputsContainer {
|
||||||
// When the game does not provide multiplayer, one field is enough
|
// When the game does not provide multiplayer, one field is enough
|
||||||
|
|||||||
Reference in New Issue
Block a user