use bevy::{
app::{App, Plugin, PostUpdate},
camera::visibility::VisibilitySystems,
ecs::{resource::Resource, schedule::IntoScheduleConfigs},
render::extract_resource::ExtractResource,
};
use crate::{light::update_point_light_bounds, render::plugin::FastLightRenderPlugin};
pub struct FastLightPlugin {
pub texture_scale: f32,
}
impl Default for FastLightPlugin {
fn default() -> Self {
Self { texture_scale: 0.5 }
}
}
impl Plugin for FastLightPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(FastLightSettings::from(self));
app.add_plugins(FastLightRenderPlugin);
app.add_systems(
PostUpdate,
update_point_light_bounds.in_set(VisibilitySystems::CalculateBounds),
);
}
}
#[derive(Resource, Clone, Copy, ExtractResource)]
pub(crate) struct FastLightSettings {
pub(crate) texture_scale: f32,
}
impl From<&FastLightPlugin> for FastLightSettings {
fn from(plugin: &FastLightPlugin) -> Self {
Self {
texture_scale: plugin.texture_scale,
}
}
}