From aaa52f0c5ff60a93e64d42bca6656b1ac0cc3719 Mon Sep 17 00:00:00 2001 From: malek Date: Fri, 29 Jul 2022 21:25:10 -0700 Subject: [PATCH] feat(add_events): added add_events macro, and some small networking events partially. --- bevy-add-events-macro/Cargo.toml | 12 ++++++++++ bevy-add-events-macro/README.md | 27 ++++++++++++++++++++++ bevy-add-events-macro/src/lib.rs | 13 +++++++++++ client/src/networking/mod.rs | 0 client/src/networking/networking_plugin.rs | 0 src/networking/mod.rs | 0 6 files changed, 52 insertions(+) create mode 100644 bevy-add-events-macro/Cargo.toml create mode 100644 bevy-add-events-macro/README.md create mode 100644 bevy-add-events-macro/src/lib.rs create mode 100644 client/src/networking/mod.rs create mode 100644 client/src/networking/networking_plugin.rs create mode 100644 src/networking/mod.rs diff --git a/bevy-add-events-macro/Cargo.toml b/bevy-add-events-macro/Cargo.toml new file mode 100644 index 0000000..abbf437 --- /dev/null +++ b/bevy-add-events-macro/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "bevy-add-events-macro" +version = "0.1.0" +edition = "2021" +authors = ["Malek "] +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] diff --git a/bevy-add-events-macro/README.md b/bevy-add-events-macro/README.md new file mode 100644 index 0000000..8914795 --- /dev/null +++ b/bevy-add-events-macro/README.md @@ -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::(); + app.add_event::(); + app.add_event::(); + app.add_event::(); + app.add_event::(); + + } + +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); + } \ No newline at end of file diff --git a/bevy-add-events-macro/src/lib.rs b/bevy-add-events-macro/src/lib.rs new file mode 100644 index 0000000..45549b9 --- /dev/null +++ b/bevy-add-events-macro/src/lib.rs @@ -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)*) + } + } +} diff --git a/client/src/networking/mod.rs b/client/src/networking/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/client/src/networking/networking_plugin.rs b/client/src/networking/networking_plugin.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/networking/mod.rs b/src/networking/mod.rs new file mode 100644 index 0000000..e69de29