From f84db61a7b4a59136abccd9103ac0ed586f3f014 Mon Sep 17 00:00:00 2001 From: WanderingPenwing Date: Sun, 6 Oct 2024 11:48:13 +0200 Subject: [PATCH] cleaned up --- src/main.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index d399077..90adc3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,9 +40,6 @@ struct Sky { content: Vec, } -#[derive(Resource, Default)] -struct ShowConstellationEvent(bool); - #[derive(Serialize, Deserialize, Debug, Clone)] struct Constellation { #[serde(rename = "Name")] @@ -85,7 +82,6 @@ fn main() { App::new() .add_plugins(DefaultPlugins) .insert_resource(Sky::default()) - .insert_resource(ShowConstellationEvent::default()) .add_systems(Startup, star_setup) .add_systems(Startup, cons_setup) .add_systems(Startup, ui_setup) @@ -99,15 +95,23 @@ fn spawn_cons_lines( mut meshes: ResMut>, mut materials: ResMut>, sky: Res, - constellation_name: String, + target_constellation_name: String, ) { - info!("show : {}", constellation_name); // Create a material for the line let line_material = materials.add(StandardMaterial { emissive: LinearRgba::rgb(1.0, 0.5, 0.5), // Red color for the line ..default() }); + let mut target_constellation = sky.content[0].clone(); + for constellation in sky.content.clone() { + if constellation.name == target_constellation_name { + target_constellation = constellation; + } + } + + info!("show : {}", target_constellation.name); + // Define vertices for the line (two points in 3D space) let vertices = vec![ [-1.0, -1.0, 0.0], // Starting point (origin) @@ -381,9 +385,9 @@ fn button_system( >, mut text_query: Query<&mut Text, With>, mut player_query: Query<&mut Player>, - mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, + commands: Commands, + meshes: ResMut>, + materials: ResMut>, sky: Res, ) { let mut pressed_button: Option = None;