Created
July 18, 2025 21:25
-
-
Save onkoe/50d14327efb3e776801c060e93f7b03e to your computer and use it in GitHub Desktop.
dumb lil idea about `ParamSet` in bevy 0.16.1
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
| #[derive(QueryData)] | |
| #[query_data(mutable)] | |
| pub struct PlayerQueryData { | |
| player_transform: &'static mut Transform, | |
| player_uuid: &'static PlayerUuid, | |
| player_view: &'static mut PlayerView, | |
| } | |
| #[derive(QueryData)] | |
| #[query_data(mutable)] | |
| pub struct PlayerHeadQueryData { | |
| head_transform: &'static mut Transform, | |
| head_uuid: &'static PlayerUuid, | |
| } | |
| param_set! { | |
| RemoteParamSet, | |
| player_query: Query<PlayerQueryData, With<Player>>, | |
| player_head_query: Query<PlayerHeadQueryData, With<PlayerHead>>, | |
| } | |
| fn some_system(mut param_set: RemoteParamSet) { | |
| { | |
| // named... as opposed to: `param_set.p0()` | |
| let mut player_query = param_set.player_query(); | |
| for PlayerQueryData { player_transform, player_uuid, player_view } in player_query { | |
| // ... | |
| } | |
| } | |
| { | |
| // again, the getter is named | |
| let mut player_head_query = param_set.player_head_query(); | |
| for PlayerHeadQueryData { head_transform, head_uuid } in player_head_query { | |
| // ... | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment