pluginize everything

This commit is contained in:
yuni 2024-03-18 00:04:23 +01:00
parent f9e76921ec
commit d95d3e8f9f
3 changed files with 35 additions and 21 deletions

View file

@ -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;

View file

@ -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(

View file

@ -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,