pluginize everything
This commit is contained in:
parent
f9e76921ec
commit
d95d3e8f9f
|
@ -1,6 +1,14 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy::audio::PlaybackMode;
|
||||
|
||||
pub struct AudioPlugin;
|
||||
impl Plugin for AudioPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, setup);
|
||||
app.add_systems(Update, toggle_bgm);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct ComponentBGM;
|
||||
|
||||
|
|
40
src/main.rs
40
src/main.rs
|
@ -5,34 +5,32 @@ mod settings;
|
|||
mod hud;
|
||||
mod actor;
|
||||
|
||||
use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode };
|
||||
use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode};
|
||||
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
|
||||
use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_systems(Startup, (
|
||||
setup,
|
||||
audio::setup,
|
||||
world::setup,
|
||||
))
|
||||
.add_systems(Update, (
|
||||
handle_input,
|
||||
audio::toggle_bgm,
|
||||
world::asset_loaded.after(world::load_cubemap_asset),
|
||||
))
|
||||
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
|
||||
.add_plugins((
|
||||
App::new().add_plugins(OutFlyPlugin).run();
|
||||
}
|
||||
|
||||
pub struct OutFlyPlugin;
|
||||
impl Plugin for OutFlyPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, setup);
|
||||
app.add_systems(Update, handle_input);
|
||||
app.insert_resource(settings::Settings::default());
|
||||
app.add_plugins((
|
||||
DefaultPlugins.set(ImagePlugin::default_nearest()),
|
||||
FrameTimeDiagnosticsPlugin,
|
||||
LogDiagnosticsPlugin::default(),
|
||||
|
||||
world::WorldPlugin,
|
||||
camera::CameraControllerPlugin,
|
||||
hud::HudPlugin,
|
||||
actor::ActorPlugin,
|
||||
))
|
||||
.add_plugins((
|
||||
FrameTimeDiagnosticsPlugin,
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
.insert_resource(settings::Settings::default())
|
||||
.run();
|
||||
audio::AudioPlugin,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(
|
||||
|
|
|
@ -7,6 +7,14 @@ use bevy::pbr::CascadeShadowConfigBuilder;
|
|||
use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings};
|
||||
use std::f32::consts::PI;
|
||||
|
||||
pub struct WorldPlugin;
|
||||
impl Plugin for WorldPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, setup);
|
||||
app.add_systems(Update, asset_loaded.after(load_cubemap_asset));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct Cubemap {
|
||||
is_loaded: bool,
|
||||
|
|
Loading…
Reference in a new issue