-
Notifications
You must be signed in to change notification settings - Fork 16
/
info_dumpeing_systems.rs
42 lines (40 loc) · 1.38 KB
/
info_dumpeing_systems.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use bevy::prelude::*;
use bevy_tnua::{TnuaGhostSensor, TnuaProximitySensor};
use crate::ui::info::InfoSource;
pub fn character_control_info_dumping_system(
mut query: Query<(
&mut InfoSource,
&TnuaProximitySensor,
Option<&TnuaGhostSensor>,
)>,
names_query: Query<&Name>,
) {
for (mut info_source, sensor, ghost_sensor) in query.iter_mut() {
if !info_source.is_active() {
continue;
}
if let Some(sensor_output) = sensor.output.as_ref() {
if let Ok(name) = names_query.get(sensor_output.entity) {
info_source.label("Standing on", name.as_str());
} else {
info_source.label("Standing on", format!("{:?}", sensor_output.entity));
}
} else {
info_source.label("Standing on", "<Nothing>");
}
if let Some(ghost_sensor) = ghost_sensor.as_ref() {
let mut text = String::new();
for hit in ghost_sensor.iter() {
if !text.is_empty() {
text.push_str(", ");
}
if let Ok(name) = names_query.get(hit.entity) {
text.push_str(name.as_str());
} else {
text.push_str(&format!("{:?}", hit.entity));
}
}
info_source.label("Ghost sensor", text);
}
}
}