#![cfg_attr(not(feature = "dev"), windows_subsystem = "windows")]
mod asset_processing;
mod asset_tracking;
mod audio;
#[cfg(feature = "dev")]
mod dev_tools;
mod gameplay;
mod hdr;
mod props;
mod screens;
mod shader_compilation;
mod theme;
mod third_party;
mod ui_camera;
use asset_processing::default_image_sampler_descriptor;
use audio::DEFAULT_VOLUME;
use bevy_landmass::LandmassSystemSet;
use bitflags::bitflags;
use bevy::{asset::AssetMetaCheck, audio::AudioPlugin, prelude::*, render::view::RenderLayers};
#[cfg(feature = "native")]
use bevy::core_pipeline::experimental::taa::TemporalAntiAliasPlugin;
use oxidized_navigation::OxidizedNavigation;
pub struct AppPlugin;
fn main() -> AppExit {
let mut app = App::new();
app.configure_sets(
Update,
(
PostPhysicsAppSystems::TickTimers,
PostPhysicsAppSystems::ChangeUi,
PostPhysicsAppSystems::PlaySounds,
PostPhysicsAppSystems::PlayAnimations,
PostPhysicsAppSystems::Update,
)
.chain(),
);
app.configure_sets(
RunFixedMainLoop,
(
PrePhysicsAppSystems::UpdateNavmeshPositions,
PrePhysicsAppSystems::UpdateNavmeshTargets,
OxidizedNavigation::RemovedComponent,
OxidizedNavigation::Main,
LandmassSystemSet::SyncExistence,
)
.chain()
.in_set(RunFixedMainLoopSystem::BeforeFixedMainLoop),
);
app.add_plugins(
DefaultPlugins
.set(AssetPlugin {
meta_check: AssetMetaCheck::Never,
..default()
})
.set(WindowPlugin {
primary_window: Window {
title: "Foxtrot".to_string(),
fit_canvas_to_parent: true,
..default()
}
.into(),
..default()
})
.set(AudioPlugin {
global_volume: GlobalVolume {
volume: DEFAULT_VOLUME,
},
..default()
})
.set(ImagePlugin {
default_sampler: default_image_sampler_descriptor(),
}),
);
app.insert_resource(AmbientLight::NONE);
#[cfg(feature = "native")]
app.add_plugins(TemporalAntiAliasPlugin);
app.add_plugins(third_party::plugin);
app.add_plugins((
asset_processing::plugin,
asset_tracking::plugin,
#[cfg(feature = "dev")]
dev_tools::plugin,
props::plugin,
screens::plugin,
theme::plugin,
ui_camera::plugin,
hdr::plugin,
));
app.add_plugins((gameplay::plugin, shader_compilation::plugin));
app.run()
}
#[derive(SystemSet, Debug, Clone, Copy, Eq, PartialEq, Hash, PartialOrd, Ord)]
enum PrePhysicsAppSystems {
UpdateNavmeshPositions,
UpdateNavmeshTargets,
}
#[derive(SystemSet, Debug, Clone, Copy, Eq, PartialEq, Hash, PartialOrd, Ord)]
enum PostPhysicsAppSystems {
TickTimers,
ChangeUi,
PlaySounds,
PlayAnimations,
Update,
}
enum CameraOrder {
World,
ViewModel,
Ui,
}
impl From<CameraOrder> for isize {
fn from(order: CameraOrder) -> Self {
order as isize
}
}
bitflags! {
struct RenderLayer: u32 {
const DEFAULT = 0b00000001;
const VIEW_MODEL = 0b00000010;
const PARTICLES = 0b00000100;
const GIZMO3 = 0b0001000;
}
}
impl From<RenderLayer> for RenderLayers {
fn from(layer: RenderLayer) -> Self {
RenderLayers::from_iter(layer.iter().map(|l| (l.bits() >> 1) as usize))
}
}