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::prelude::*;
use bevy::audio::PlaybackMode; 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)] #[derive(Component)]
pub struct ComponentBGM; pub struct ComponentBGM;

View file

@ -5,34 +5,32 @@ mod settings;
mod hud; mod hud;
mod actor; mod actor;
use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode }; use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode};
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}; use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
use bevy::prelude::*; use bevy::prelude::*;
fn main() { fn main() {
App::new() App::new().add_plugins(OutFlyPlugin).run();
.add_systems(Startup, ( }
setup,
audio::setup, pub struct OutFlyPlugin;
world::setup, impl Plugin for OutFlyPlugin {
)) fn build(&self, app: &mut App) {
.add_systems(Update, ( app.add_systems(Startup, setup);
handle_input, app.add_systems(Update, handle_input);
audio::toggle_bgm, app.insert_resource(settings::Settings::default());
world::asset_loaded.after(world::load_cubemap_asset), app.add_plugins((
)) DefaultPlugins.set(ImagePlugin::default_nearest()),
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) FrameTimeDiagnosticsPlugin,
.add_plugins(( LogDiagnosticsPlugin::default(),
world::WorldPlugin,
camera::CameraControllerPlugin, camera::CameraControllerPlugin,
hud::HudPlugin, hud::HudPlugin,
actor::ActorPlugin, actor::ActorPlugin,
)) audio::AudioPlugin,
.add_plugins(( ));
FrameTimeDiagnosticsPlugin, }
LogDiagnosticsPlugin::default(),
))
.insert_resource(settings::Settings::default())
.run();
} }
fn setup( fn setup(

View file

@ -7,6 +7,14 @@ use bevy::pbr::CascadeShadowConfigBuilder;
use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings}; use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings};
use std::f32::consts::PI; 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)] #[derive(Resource)]
pub struct Cubemap { pub struct Cubemap {
is_loaded: bool, is_loaded: bool,