@@ -13,12 +13,14 @@ use bevy::{
1313} ;
1414use rand:: RngExt ;
1515
16- use crate :: generate_city:: { spawn_city, CityRoot } ;
17- use crate :: { assets:: CityAssets , CitySpawned } ;
16+ use crate :: assets:: CityAssets ;
17+ use crate :: generate_city:: { spawn_city, CityRoot , TrafficLight } ;
18+ use crate :: CitySpawned ;
1819
1920#[ derive( Resource ) ]
2021pub struct Settings {
2122 pub simulate_cars : bool ,
23+ pub traffic_lights : bool ,
2224 pub shadow_maps_enabled : bool ,
2325 pub contact_shadows_enabled : bool ,
2426 pub wireframe_enabled : bool ,
@@ -29,6 +31,7 @@ impl Default for Settings {
2931 fn default ( ) -> Self {
3032 Self {
3133 simulate_cars : true ,
34+ traffic_lights : true ,
3235 shadow_maps_enabled : true ,
3336 contact_shadows_enabled : true ,
3437 wireframe_enabled : false ,
@@ -71,6 +74,20 @@ pub fn settings_ui() -> impl Scene {
7174 } )
7275 Children [ ( Text ( "Simulate Cars" ) ThemedText ) ]
7376 ) ,
77+ (
78+ checkbox( )
79+ Checked
80+ on( checkbox_self_update)
81+ on( |change: On <ValueChange <bool >>, mut settings: ResMut <Settings >, mut traffic_light: Query <& mut Visibility , With <TrafficLight >>| {
82+ settings. traffic_lights = change. value;
83+ let vis = if change. value { Visibility :: Inherited } else { Visibility :: Hidden } ;
84+ for mut v in & mut traffic_light {
85+ * v = vis;
86+ }
87+ } )
88+ Children [ ( Text ( "Traffic lights" ) ThemedText ) ]
89+ ) ,
90+
7491 (
7592 checkbox( )
7693 Checked
0 commit comments