Last active
September 3, 2024 07:49
-
-
Save RJ/c746cf782f6b9dc4022498d44de38013 to your computer and use it in GitHub Desktop.
return a system from a function, enclosing something useful
This file contains hidden or 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
/* | |
Sometimes you want to dump some component values in multiple different schedules | |
like when debugging network replication.. | |
here's an example of a function you can use to enclose the schedule name you put it in: | |
```rust | |
app.add_systems(Update, dumper("Update")); | |
app.add_systems(Last, dumper("Last")); | |
``` | |
*/ | |
fn dumper(name: &str) -> bevy::ecs::schedule::SystemConfigs { | |
let name = String::from(name); | |
(move |q: Query<(Entity, &Position, &Transform), With<Player>>, tick_manager: Res<TickManager>| { | |
let tick = tick_manager.tick(); | |
for (e, pos, trans) in q.iter() { | |
info!("{name} @ {tick:?} {e:?} {pos:?} {trans:?}"); | |
} | |
}) | |
.into_configs() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment