-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from hyoi/refactoring_0.12
0.12.0のリリース(Refactoring)
- Loading branch information
Showing
67 changed files
with
4,499 additions
and
3,480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
[package] | ||
name = "tigtag" | ||
version = "0.11.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
#bevy = { git = "https://github.com/bevyengine/bevy" } #Master branch | ||
bevy = "0.13" | ||
once_cell = "1" | ||
rand = "0.8" | ||
regex = "1" | ||
|
||
# WASMの場合にどれか指定する必要がある?? | ||
# rand = { version = "0.8.4", features = [ "wasm-bindgen" ] } | ||
# getrandom = { version = "0.2.4", features = [ "js" ] } | ||
# getrandom = { version = "0.2.4", features = [ "wasm-bindgen" ] } | ||
[workspace] | ||
resolver = "2" | ||
members = [ "tigtag", "macros" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "macros" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] | ||
#syn = { version = "2.0", features = [ "extra-traits" ] } | ||
syn = "2.0" | ||
quote = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//import external modules | ||
use proc_macro::TokenStream; | ||
use syn::*; | ||
use quote::*; | ||
|
||
//#[derive( MyState )]を作る | ||
#[proc_macro_derive( MyState )] | ||
pub fn derive( input: TokenStream ) -> TokenStream | ||
{ //入力を分解する | ||
let ast = parse_macro_input!( input as DeriveInput ); | ||
let enum_type = ast.ident; | ||
|
||
//バリアントの名前を保存する | ||
let mut variant = Vec::new(); | ||
match ast.data | ||
{ Data::Enum( my_enum ) => | ||
{ for my_variant in my_enum.variants.into_iter() | ||
{ { variant.push( my_variant.ident ); | ||
} | ||
} | ||
} | ||
_ => panic!( "Only Enum can be applied." ) | ||
} | ||
|
||
//文字列を作成して出力する | ||
let expand = quote! | ||
{ //MyStateの遷移に使うTrait境界 | ||
pub trait ChangeMyState { fn state( &self ) -> #enum_type; } | ||
|
||
//バリアントと同名のstructからバリアントを取得できるように仕込む | ||
#( #[derive( Default )] pub struct #variant; | ||
impl ChangeMyState for #variant | ||
{ fn state( &self ) -> #enum_type { #enum_type::#variant } | ||
} | ||
)* | ||
|
||
//型(struct)によって指定されたMyStateへ遷移する | ||
pub fn change_state_to<T: Send + Sync + Default + ChangeMyState> | ||
( next: Local<T>, | ||
mut next_state: ResMut<NextState< #enum_type >> | ||
) | ||
{ next_state.set( next.state() ); | ||
} | ||
|
||
//ResourceにセットされたMyStateへ遷移する | ||
pub fn change_state_by<T: Resource + ChangeMyState> | ||
( opt_state: Option<Res<T>>, | ||
mut next_state: ResMut<NextState< #enum_type >> | ||
) | ||
{ let Some ( next ) = opt_state else { warn!( "opt_state is None." ); return }; | ||
next_state.set( next.state() ); | ||
} | ||
}; | ||
expand.into() | ||
} | ||
|
||
//End of code. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.