add a bunch of asteroids + actor count in hud
This commit is contained in:
parent
1e7fc6030b
commit
2361209eab
23
src/hud.rs
23
src/hud.rs
|
@ -146,6 +146,24 @@ fn setup(
|
||||||
..default()
|
..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(
|
TextSection::new(
|
||||||
"\n\n",
|
"\n\n",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
|
@ -182,6 +200,7 @@ fn update(
|
||||||
player: Query<(&actor::Suit, &actor::LifeForm), With<actor::Player>>,
|
player: Query<(&actor::Suit, &actor::LifeForm), With<actor::Player>>,
|
||||||
mut timer: ResMut<FPSUpdateTimer>,
|
mut timer: ResMut<FPSUpdateTimer>,
|
||||||
mut query: Query<&mut Text, With<GaugesText>>,
|
mut query: Query<&mut Text, With<GaugesText>>,
|
||||||
|
query_all_actors: Query<&actor::Actor>,
|
||||||
) {
|
) {
|
||||||
if timer.0.tick(time.delta()).just_finished() {
|
if timer.0.tick(time.delta()).just_finished() {
|
||||||
let player = player.get_single();
|
let player = player.get_single();
|
||||||
|
@ -201,11 +220,13 @@ fn update(
|
||||||
text.sections[5].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg]");
|
text.sections[5].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg]");
|
||||||
let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
|
let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
|
||||||
text.sections[7].value = format!("{adrenaline:.0}pg/mL");
|
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 {
|
for mut text in &mut query {
|
||||||
let logs_vec: Vec<&str> = log.logs.iter().map(|s| s.text.as_str()).collect();
|
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();
|
log.remove_old();
|
||||||
}
|
}
|
||||||
|
|
28
src/world.rs
28
src/world.rs
|
@ -104,6 +104,34 @@ pub fn setup(
|
||||||
..default()
|
..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
|
// Add THE SUN
|
||||||
let hydrogenfusion_handle = materials.add(StandardMaterial {
|
let hydrogenfusion_handle = materials.add(StandardMaterial {
|
||||||
emissive: Color::rgb_linear(1e6, 0.9e6, 1e6),
|
emissive: Color::rgb_linear(1e6, 0.9e6, 1e6),
|
||||||
|
|
Loading…
Reference in a new issue