add a bunch of asteroids + actor count in hud

This commit is contained in:
yuni 2024-03-18 03:42:14 +01:00
parent 1e7fc6030b
commit 2361209eab
2 changed files with 50 additions and 1 deletions

View file

@ -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<actor::Player>>,
mut timer: ResMut<FPSUpdateTimer>,
mut query: Query<&mut Text, With<GaugesText>>,
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();
}

View file

@ -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),