-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[demos] Add info "tab" to GUI, and show in it the names of the object…
…s the character stands on.
- Loading branch information
Showing
10 changed files
with
245 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
demos/src/character_control_systems/info_dumpeing_systems.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod info_dumpeing_systems; | ||
pub mod platformer_control_systems; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.