feat(add_events): added add_events macro, and some small networking events partially.
This commit is contained in:
parent
db00616184
commit
aaa52f0c5f
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "bevy-add-events-macro"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
authors = ["Malek <pocmalek@gmail.com>"]
|
||||||
|
description = "A macro to add multiple events to a bevy app easily"
|
||||||
|
repository = "https://git.tebibyte.media/nexus"
|
||||||
|
publish = true
|
||||||
|
license = "MIT"
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
|
@ -0,0 +1,27 @@
|
||||||
|
This is a macro to add events.
|
||||||
|
Given these events:
|
||||||
|
|
||||||
|
struct Event1;
|
||||||
|
struct Event2;
|
||||||
|
struct Event3;
|
||||||
|
struct Event4;
|
||||||
|
struct Event5;
|
||||||
|
|
||||||
|
This is the code you have to normally write in bevy
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
let mut app = App::new();
|
||||||
|
app.add_event::<Event1>();
|
||||||
|
app.add_event::<Event2>();
|
||||||
|
app.add_event::<Event3>();
|
||||||
|
app.add_event::<Event4>();
|
||||||
|
app.add_event::<Event5>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
And this is the code you can write with the add_events! macro!
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
let mut app = App::new();
|
||||||
|
add_events!(app, Event1, Event2, Event3, Event4, Event5);
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! add_events{
|
||||||
|
($a:ident,$b:ty)=>{
|
||||||
|
{
|
||||||
|
$a.add_event::<$b>()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
($a:ident,$b:ty $(,$c:ty)*)=> {
|
||||||
|
{
|
||||||
|
add_events!($a, $b); add_events!($a $(,$c)*)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue