feat(derive): add Action derive macro
This commit is contained in:
+18
@@ -308,6 +308,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"bevy_controls",
|
"bevy_controls",
|
||||||
|
"bevy_controls_derive",
|
||||||
"strum",
|
"strum",
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
]
|
]
|
||||||
@@ -318,6 +319,7 @@ version = "0.12.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e4bc7e09282a82a48d70ade0c4c1154b0fd7882a735a39c66766a5d0f4718ea9"
|
checksum = "e4bc7e09282a82a48d70ade0c4c1154b0fd7882a735a39c66766a5d0f4718ea9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bevy_dylib",
|
||||||
"bevy_internal",
|
"bevy_internal",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -407,6 +409,13 @@ dependencies = [
|
|||||||
"strum_macros",
|
"strum_macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bevy_controls_derive"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bevy_controls",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_core"
|
name = "bevy_core"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
@@ -470,6 +479,15 @@ dependencies = [
|
|||||||
"sysinfo",
|
"sysinfo",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bevy_dylib"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "45b99001eb4837c78d9c63cc8b32fda61ea96b194a2cda54b569aeee69a9853c"
|
||||||
|
dependencies = [
|
||||||
|
"bevy_internal",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_ecs"
|
name = "bevy_ecs"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ bevy = { version = "0.12.1", default-features = false, features = [
|
|||||||
"bevy_asset",
|
"bevy_asset",
|
||||||
"bevy_text",
|
"bevy_text",
|
||||||
"bevy_ui",
|
"bevy_ui",
|
||||||
|
"dynamic_linking",
|
||||||
"default_font",
|
"default_font",
|
||||||
]}
|
]}
|
||||||
bevy_controls = { path = "./../../" }
|
bevy_controls = { path = "./../../" }
|
||||||
|
bevy_controls_derive = { path = "./../../../bevy_controls_derive" }
|
||||||
strum = "0.25.0"
|
strum = "0.25.0"
|
||||||
strum_macros = "0.25.3"
|
strum_macros = "0.25.3"
|
||||||
|
|||||||
@@ -13,12 +13,11 @@ use bevy_controls::{
|
|||||||
Action, ActionInner, GameState, GameStateInner, InputsContainer, InputsContainerInner,
|
Action, ActionInner, GameState, GameStateInner, InputsContainer, InputsContainerInner,
|
||||||
},
|
},
|
||||||
plugin::ControlsPlugin,
|
plugin::ControlsPlugin,
|
||||||
resource::{Binding, ButtonCombination, Controls, InputType, InputValue, Inputs, PlayerInputs},
|
resource::{Binding, ButtonCombination, Controls, InputType, InputValue, PlayerInputs},
|
||||||
};
|
};
|
||||||
use strum_macros::EnumIter;
|
use strum_macros::EnumIter;
|
||||||
const FIRA_CODE_PATH: &str = "font/FiraCode/FiraCode-VariableFont_wght.ttf";
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, EnumIter, Clone, Copy, Debug)]
|
#[derive(PartialEq, Eq, Hash, EnumIter, Clone, Copy, Debug, bevy_controls_derive::Action)]
|
||||||
enum MyAction {
|
enum MyAction {
|
||||||
Forward,
|
Forward,
|
||||||
Back,
|
Back,
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
[package]
|
||||||
|
name = "bevy_controls_derive"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
proc-macro = true
|
||||||
|
|
||||||
|
# [features]
|
||||||
|
# default = []
|
||||||
|
# serialize = ["bevy_input/serialize", "serde"]
|
||||||
|
# reflect = ["dep:bevy_reflect"]
|
||||||
|
# inspector-egui = ["reflect", "dep:bevy-inspector-egui"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
# bevy-inspector-egui = { version = "0.22.1", optional = true }
|
||||||
|
# bevy_app = "0.12.1"
|
||||||
|
# bevy_derive = "0.12.1"
|
||||||
|
# bevy_ecs = "0.12.1"
|
||||||
|
# bevy_input = "0.12.1"
|
||||||
|
# bevy_reflect = { version = "0.12.1", optional = true }
|
||||||
|
# bevy_utils = "0.12.1"
|
||||||
|
# log = "0.4.20"
|
||||||
|
# serde = { version = "1.0.194", optional = true }
|
||||||
|
# strum = "0.25.0"
|
||||||
|
# strum_macros = "0.25.3"
|
||||||
|
bevy_controls = { path = "./../bevy_controls" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
env_logger = "0.10.1"
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
extern crate proc_macro;
|
||||||
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
|
#[proc_macro_derive(Action)]
|
||||||
|
pub fn action(_input: TokenStream) -> TokenStream {
|
||||||
|
todo!("urmom")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user