use bevy::anti_alias::fxaa::Fxaa; use bevy::app::{App, Startup}; use bevy::core_pipeline::tonemapping::DebandDither; use bevy::post_process::bloom::Bloom; use crate::ecs::{GameplayState, MAIN_LAYER, MAIN_STAR_LAYERS, MainCamera, Me, StarguideCamera}; use crate::prelude::*; pub fn render_plugin(app: &mut App) { app .add_systems(Startup, setup_graphics) .add_systems(Update, follow_camera.run_if(in_state(GameplayState::Main))); } pub fn setup_graphics(mut config_store: ResMut, mut commands: Commands) { commands .spawn(Camera2d) .insert(Camera { clear_color: ClearColorConfig::Custom(Color::BLACK), ..default() }) .insert(MAIN_LAYER) .insert(Bloom::default()) .insert(DebandDither::Enabled) .insert(Fxaa::default()) .insert(MainCamera); for (_, config, _) in config_store.iter_mut() { config.render_layers = MAIN_STAR_LAYERS.clone(); } } fn follow_camera( mut camera: Query<&mut Transform, (With, Without)>, mut starguide_camera: Query<&mut Transform, (With, Without, Without)>, player: Query<&Transform, With>, ) { let mut camera = camera.single_mut().unwrap(); let Ok(player) = player.single() else { return; }; camera.translation = player.translation; }