Skip to content

Commit b4f660a

Browse files
committed
night vs day skylight
1 parent 0c81cb9 commit b4f660a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lighting/plugin.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ use bevy::{
44
};
55
use bevy_magic_light_2d::prelude::*;
66

7+
use crate::components::State;
8+
79

810
pub struct LightingPlugin;
911

1012
impl Plugin for LightingPlugin {
1113
fn build(&self, app: &mut App) {
12-
app.add_systems(Startup, generate_lights.after(setup_post_processing_camera));
14+
app.add_systems(Startup, generate_lights.after(setup_post_processing_camera))
15+
.add_systems(Update, update_lights);
1316
}
1417
}
1518

@@ -50,3 +53,14 @@ fn generate_lights(mut commands: Commands) {
5053
Name::new("global_skylight"),
5154
)); */
5255
}
56+
57+
fn update_lights(mut query: Query<&mut SkylightLight2D>, state: Res<State>) {
58+
let mut skylight = query.single_mut();
59+
60+
let intensity = match state.global.is_day() {
61+
true => 0.025,
62+
false => 0.,
63+
};
64+
65+
skylight.intensity = intensity
66+
}

0 commit comments

Comments
 (0)