Crate unification (#88)
* move client/server/config into shared * move platforms into shared * move head drops into shared * move tb_entities to shared * reduce server to just a call into shared * get solo play working * fix server opening window * fix fmt * extracted a few more modules from client * near completely migrated client * fixed duplicate CharacterInputEnabled definition * simplify a few things related to builds * more simplifications * fix warnings/check * ci update * address comments * try fixing macos steam build * address comments * address comments * CI tweaks with default client feature --------- Co-authored-by: PROMETHIA-27 <electriccobras@gmail.com>
This commit is contained in:
90
crates/hedz_reloaded/src/client/setup.rs
Normal file
90
crates/hedz_reloaded/src/client/setup.rs
Normal file
@@ -0,0 +1,90 @@
|
||||
use crate::{DebugVisuals, GameState, camera::MainCamera, loading_assets::AudioAssets};
|
||||
use bevy::{
|
||||
audio::{PlaybackMode, Volume},
|
||||
core_pipeline::tonemapping::Tonemapping,
|
||||
prelude::*,
|
||||
render::view::ColorGrading,
|
||||
};
|
||||
use bevy_trenchbroom::TrenchBroomServer;
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
#[cfg(feature = "dbg")]
|
||||
{
|
||||
app.add_plugins(bevy_inspector_egui::bevy_egui::EguiPlugin::default());
|
||||
app.add_plugins(bevy_inspector_egui::quick::WorldInspectorPlugin::new());
|
||||
app.add_plugins(avian3d::prelude::PhysicsDebugPlugin::default());
|
||||
}
|
||||
|
||||
app.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 400.,
|
||||
..Default::default()
|
||||
});
|
||||
app.insert_resource(ClearColor(Color::BLACK));
|
||||
//TODO: let user control this
|
||||
app.insert_resource(GlobalVolume::new(Volume::Linear(0.4)));
|
||||
|
||||
app.add_systems(Startup, write_trenchbroom_config);
|
||||
app.add_systems(OnEnter(GameState::Playing), music);
|
||||
app.add_systems(Update, (set_materials_unlit, set_tonemapping, set_shadows));
|
||||
}
|
||||
|
||||
fn music(assets: Res<AudioAssets>, mut commands: Commands) {
|
||||
commands.spawn((
|
||||
Name::new("sfx-music"),
|
||||
AudioPlayer::new(assets.music.clone()),
|
||||
PlaybackSettings {
|
||||
mode: PlaybackMode::Loop,
|
||||
volume: Volume::Linear(0.6),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
|
||||
commands.spawn((
|
||||
Name::new("sfx-ambient"),
|
||||
AudioPlayer::new(assets.ambient.clone()),
|
||||
PlaybackSettings {
|
||||
mode: PlaybackMode::Loop,
|
||||
volume: Volume::Linear(0.8),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
fn write_trenchbroom_config(server: Res<TrenchBroomServer>, type_registry: Res<AppTypeRegistry>) {
|
||||
if let Err(e) = server
|
||||
.config
|
||||
.write_game_config("trenchbroom/hedz", &type_registry.read())
|
||||
{
|
||||
warn!("Failed to write trenchbroom config: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
fn set_tonemapping(
|
||||
mut cams: Query<(&mut Tonemapping, &mut ColorGrading), With<MainCamera>>,
|
||||
visuals: Res<DebugVisuals>,
|
||||
) {
|
||||
for (mut tm, mut color) in cams.iter_mut() {
|
||||
*tm = visuals.tonemapping;
|
||||
color.global.exposure = visuals.exposure;
|
||||
}
|
||||
}
|
||||
|
||||
fn set_materials_unlit(
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
visuals: Res<DebugVisuals>,
|
||||
) {
|
||||
if !materials.is_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
for (_, material) in materials.iter_mut() {
|
||||
material.unlit = visuals.unlit;
|
||||
}
|
||||
}
|
||||
|
||||
fn set_shadows(mut lights: Query<&mut DirectionalLight>, visuals: Res<DebugVisuals>) {
|
||||
for mut l in lights.iter_mut() {
|
||||
l.shadows_enabled = visuals.shadows;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user