|
|
|
@ -57,6 +57,12 @@ impl Plugin for Display3dPlugin {
|
|
|
|
remove_valid_move_entity.run_if(any_component_removed::<game::Selected>()),
|
|
|
|
remove_valid_move_entity.run_if(any_component_removed::<game::Selected>()),
|
|
|
|
set_valid_move_model.run_if(any_component_added::<game::ValidMove>),
|
|
|
|
set_valid_move_model.run_if(any_component_added::<game::ValidMove>),
|
|
|
|
update_tweaks.run_if(on_event::<AssetEvent<Tweaks>>()),
|
|
|
|
update_tweaks.run_if(on_event::<AssetEvent<Tweaks>>()),
|
|
|
|
|
|
|
|
scale_lighting.run_if(
|
|
|
|
|
|
|
|
any_component_added::<DirectionalLight>
|
|
|
|
|
|
|
|
.or_else(any_component_added::<SpotLight>)
|
|
|
|
|
|
|
|
.or_else(any_component_added::<PointLight>)
|
|
|
|
|
|
|
|
.or_else(on_event::<AssetEvent<Tweaks>>())
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
@ -1005,6 +1011,52 @@ fn switch_sides(
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn scale_lighting(
|
|
|
|
|
|
|
|
mut directional: Query<(Entity, &mut DirectionalLight, Option<&Original<DirectionalLight>>)>,
|
|
|
|
|
|
|
|
mut spot: Query<(Entity, &mut SpotLight, Option<&Original<SpotLight>>)>,
|
|
|
|
|
|
|
|
mut point: Query<(Entity, &mut PointLight, Option<&Original<PointLight>>)>,
|
|
|
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
let tweak = tweaks
|
|
|
|
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let directional_tweak = tweak.get::<f32>("display3d_lights_scaling_directional").expect("Directional lighting scalar");
|
|
|
|
|
|
|
|
directional.iter_mut().for_each(|(entity, mut val, original)| {
|
|
|
|
|
|
|
|
info!("Scaling directional light {:?}", entity);
|
|
|
|
|
|
|
|
if let Some(Original(v)) = original {
|
|
|
|
|
|
|
|
val.illuminance = v.illuminance * directional_tweak;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
commands.entity(entity).insert(Original(val.clone()));
|
|
|
|
|
|
|
|
val.illuminance *= directional_tweak;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let spot_tweak = tweak.get::<f32>("display3d_lights_scaling_spot").expect("Spot lighting scalar");
|
|
|
|
|
|
|
|
spot.iter_mut().for_each(|(entity, mut val, original)| {
|
|
|
|
|
|
|
|
info!("Scaling spot light {:?}", entity);
|
|
|
|
|
|
|
|
if let Some(Original(v)) = original {
|
|
|
|
|
|
|
|
val.intensity = v.intensity * spot_tweak;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
commands.entity(entity).insert(Original(val.clone()));
|
|
|
|
|
|
|
|
val.intensity *= spot_tweak;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let point_tweak = tweak.get::<f32>("display3d_lights_scaling_point").expect("Point lighting scalar");
|
|
|
|
|
|
|
|
point.iter_mut().for_each(|(entity, mut val, original)| {
|
|
|
|
|
|
|
|
info!("Scaling point light {:?}", entity);
|
|
|
|
|
|
|
|
if let Some(Original(v)) = original {
|
|
|
|
|
|
|
|
val.intensity = v.intensity * point_tweak;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
commands.entity(entity).insert(Original(val.clone()));
|
|
|
|
|
|
|
|
val.intensity *= point_tweak;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(super) mod tweaks {
|
|
|
|
pub(super) mod tweaks {
|
|
|
|
use bevy::{
|
|
|
|
use bevy::{
|
|
|
|
core_pipeline::tonemapping::Tonemapping,
|
|
|
|
core_pipeline::tonemapping::Tonemapping,
|
|
|
|
|