2024-03-16 19:53:57 +00:00
|
|
|
mod audio;
|
2024-03-16 20:00:40 +00:00
|
|
|
mod camera;
|
2024-03-16 20:44:51 +00:00
|
|
|
mod world;
|
2024-03-16 21:20:23 +00:00
|
|
|
mod settings;
|
2024-03-17 14:23:22 +00:00
|
|
|
mod hud;
|
2024-03-17 22:49:50 +00:00
|
|
|
mod actor;
|
2024-03-16 19:53:57 +00:00
|
|
|
|
2024-03-18 22:47:03 +00:00
|
|
|
#[allow(dead_code)]
|
|
|
|
mod nature;
|
|
|
|
|
2024-03-17 23:04:23 +00:00
|
|
|
use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode};
|
2024-03-18 03:41:52 +00:00
|
|
|
use bevy::diagnostic::FrameTimeDiagnosticsPlugin;
|
2024-03-16 20:44:51 +00:00
|
|
|
use bevy::prelude::*;
|
2024-03-22 10:49:34 +00:00
|
|
|
use bevy_embedded_assets::{EmbeddedAssetPlugin, PluginMode};
|
2024-03-16 14:00:31 +00:00
|
|
|
|
2024-03-16 13:27:22 +00:00
|
|
|
fn main() {
|
2024-03-22 11:06:03 +00:00
|
|
|
if cfg!(debug_assertions) {
|
|
|
|
App::new().add_plugins((
|
|
|
|
OutFlyPlugin,
|
|
|
|
)).run();
|
|
|
|
} else {
|
|
|
|
App::new().add_plugins((
|
|
|
|
EmbeddedAssetPlugin { mode: PluginMode::ReplaceDefault },
|
|
|
|
OutFlyPlugin,
|
|
|
|
)).run();
|
|
|
|
}
|
2024-03-17 23:04:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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((
|
2024-03-18 19:58:16 +00:00
|
|
|
DefaultPlugins,//.set(ImagePlugin::default_nearest()),
|
2024-03-17 23:04:23 +00:00
|
|
|
FrameTimeDiagnosticsPlugin,
|
|
|
|
|
|
|
|
world::WorldPlugin,
|
2024-03-17 14:23:22 +00:00
|
|
|
camera::CameraControllerPlugin,
|
2024-03-17 22:49:50 +00:00
|
|
|
hud::HudPlugin,
|
|
|
|
actor::ActorPlugin,
|
2024-03-17 23:04:23 +00:00
|
|
|
audio::AudioPlugin,
|
|
|
|
));
|
|
|
|
}
|
2024-03-16 14:00:31 +00:00
|
|
|
}
|
|
|
|
|
2024-03-16 18:07:28 +00:00
|
|
|
fn setup(
|
|
|
|
mut windows: Query<&mut Window, With<PrimaryWindow>>
|
|
|
|
) {
|
|
|
|
for mut window in &mut windows {
|
|
|
|
window.cursor.grab_mode = CursorGrabMode::Locked;
|
|
|
|
window.cursor.visible = false;
|
|
|
|
window.mode = WindowMode::Fullscreen;
|
2024-03-16 23:24:47 +00:00
|
|
|
window.title = "OutFly".to_string();
|
2024-03-16 18:07:28 +00:00
|
|
|
}
|
2024-03-16 15:22:44 +00:00
|
|
|
}
|
|
|
|
|
2024-03-16 15:12:35 +00:00
|
|
|
fn handle_input(
|
|
|
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
2024-03-17 17:26:44 +00:00
|
|
|
mut settings: ResMut<settings::Settings>,
|
2024-03-16 15:12:35 +00:00
|
|
|
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>
|
|
|
|
) {
|
2024-03-18 03:39:26 +00:00
|
|
|
if keyboard_input.pressed(settings.key_exit) {
|
2024-03-16 15:12:35 +00:00
|
|
|
app_exit_events.send(bevy::app::AppExit);
|
2024-03-16 14:13:00 +00:00
|
|
|
}
|
2024-03-18 03:39:26 +00:00
|
|
|
if keyboard_input.just_pressed(settings.key_restart) {
|
2024-03-17 17:26:44 +00:00
|
|
|
settings.reset();
|
2024-03-16 21:20:23 +00:00
|
|
|
}
|
2024-03-16 14:13:00 +00:00
|
|
|
}
|