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