From 2361209eabdf88de0c7ad5063ba35cd2e25dd747 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 18 Mar 2024 03:42:14 +0100 Subject: [PATCH] add a bunch of asteroids + actor count in hud --- src/hud.rs | 23 ++++++++++++++++++++++- src/world.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/hud.rs b/src/hud.rs index ae93afb..c82c278 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -146,6 +146,24 @@ fn setup( ..default() } ), + TextSection::new( + "\nProximity 警告 ", + TextStyle { + font: asset_server.load(FONT), + font_size: settings.font_size_hud, + color: Color::GRAY, + ..default() + }, + ), + TextSection::new( + "", + TextStyle { + font: asset_server.load(FONT), + font_size: settings.font_size_hud, + color: Color::GRAY, + ..default() + } + ), TextSection::new( "\n\n", TextStyle { @@ -182,6 +200,7 @@ fn update( player: Query<(&actor::Suit, &actor::LifeForm), With>, mut timer: ResMut, mut query: Query<&mut Text, With>, + query_all_actors: Query<&actor::Actor>, ) { if timer.0.tick(time.delta()).just_finished() { let player = player.get_single(); @@ -201,11 +220,13 @@ fn update( text.sections[5].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg]"); let adrenaline = lifeform.adrenaline * 990.0 + 10.0; text.sections[7].value = format!("{adrenaline:.0}pg/mL"); + let all_actors = query_all_actors.iter().len(); + text.sections[9].value = format!("{all_actors:.0}"); } } for mut text in &mut query { let logs_vec: Vec<&str> = log.logs.iter().map(|s| s.text.as_str()).collect(); - text.sections[9].value = logs_vec.join("\n"); + text.sections[11].value = logs_vec.join("\n"); } log.remove_old(); } diff --git a/src/world.rs b/src/world.rs index 92d7a56..cae6e29 100644 --- a/src/world.rs +++ b/src/world.rs @@ -104,6 +104,34 @@ pub fn setup( ..default() }); + // Add a bunch of asteriods + let sphere_radius = 10.0; + let sphere_handle = meshes.add(Sphere::new(sphere_radius)); + let asteroid_color_handle = materials.add(StandardMaterial { + base_color: Color::rgb(0.4, 0.3, 0.1), + perceptual_roughness: 1.0, + ..default() + }); + for i in -20..20 { + for j in -20..20 { + for k in -20..20 { + commands.spawn(( + actor::Actor::default(), + PbrBundle { + mesh: sphere_handle.clone(), + material: asteroid_color_handle.clone(), + transform: Transform::from_xyz( + 200.0 * i as f32, + 400.0 * j as f32, + 250.0 * k as f32, + ), + ..default() + } + )); + } + } + } + // Add THE SUN let hydrogenfusion_handle = materials.add(StandardMaterial { emissive: Color::rgb_linear(1e6, 0.9e6, 1e6),