2020-10-29 20:04:28 +00:00
|
|
|
use bevy::{app::PluginGroupBuilder, prelude::*};
|
|
|
|
|
|
|
|
/// PluginGroups are a way to group sets of plugins that should be registered together.
|
|
|
|
fn main() {
|
2021-07-27 20:21:06 +00:00
|
|
|
App::new()
|
2020-11-03 02:38:37 +00:00
|
|
|
// Two PluginGroups that are included with bevy are DefaultPlugins and MinimalPlugins
|
2020-11-03 03:01:17 +00:00
|
|
|
.add_plugins(DefaultPlugins)
|
2020-10-29 20:04:28 +00:00
|
|
|
// Adding a plugin group adds all plugins in the group by default
|
2020-11-03 03:01:17 +00:00
|
|
|
.add_plugins(HelloWorldPlugins)
|
2020-10-29 20:04:28 +00:00
|
|
|
// You can also modify a PluginGroup (such as disabling plugins) like this:
|
2020-11-03 03:01:17 +00:00
|
|
|
// .add_plugins_with(HelloWorldPlugins, |group| {
|
2020-10-29 20:04:28 +00:00
|
|
|
// group
|
|
|
|
// .disable::<PrintWorldPlugin>()
|
2021-03-11 00:27:30 +00:00
|
|
|
// .add_before::<PrintHelloPlugin,
|
|
|
|
// _>(bevy::diagnostic::LogDiagnosticsPlugin::default()) })
|
2020-10-29 20:04:28 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A group of plugins that produce the "hello world" behavior
|
|
|
|
pub struct HelloWorldPlugins;
|
|
|
|
|
|
|
|
impl PluginGroup for HelloWorldPlugins {
|
|
|
|
fn build(&mut self, group: &mut PluginGroupBuilder) {
|
|
|
|
group.add(PrintHelloPlugin).add(PrintWorldPlugin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct PrintHelloPlugin;
|
|
|
|
|
|
|
|
impl Plugin for PrintHelloPlugin {
|
2021-07-27 20:21:06 +00:00
|
|
|
fn build(&self, app: &mut App) {
|
2020-12-16 05:57:16 +00:00
|
|
|
app.add_system(print_hello_system.system());
|
2020-10-29 20:04:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn print_hello_system() {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("hello");
|
2020-10-29 20:04:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct PrintWorldPlugin;
|
|
|
|
|
|
|
|
impl Plugin for PrintWorldPlugin {
|
2021-07-27 20:21:06 +00:00
|
|
|
fn build(&self, app: &mut App) {
|
2020-12-16 05:57:16 +00:00
|
|
|
app.add_system(print_world_system.system());
|
2020-10-29 20:04:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn print_world_system() {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("world");
|
2020-10-29 20:04:28 +00:00
|
|
|
}
|