now you're thinking with functions (and piping)

main
Elijah Voigt 2 years ago
parent a6cc91aacc
commit 7549f230bf

@ -780,18 +780,23 @@ mod animations {
pub fn add_animations_ui(
player_spawned: Query<&Name, Added<AnimationPlayer>>,
widget: Query<Entity, With<AnimationWidget>>,
gltfs: Res<Assets<Gltf>>,
mut commands: Commands,
gltfs: Res<Assets<Gltf>>,
clips: Res<Assets<AnimationClip>>,
) {
player_spawned.iter().for_each(|player_name| {
gltfs.iter().for_each(|(_, gltf)| {
gltf.named_animations
gltfs
.iter()
.for_each(|(clip_name, handle)| {
info!("Checking clip {:?}", clip_name);
let clip = clips.get(&handle).expect("load animation clip");
clip.compatible_with(player_name).then(|| {
.flat_map(|(_, gltf)| gltf.named_animations.iter())
.filter_map(|(clip_name, handle)| {
if let Some(clip) = clips.get(&handle) {
Some((clip_name, handle, clip))
} else {
None
}
})
.filter(|(_, _, clip)| clip.compatible_with(player_name))
.for_each(|(clip_name, handle, _)| {
create_asset_button(
&widget,
&mut commands,
@ -803,8 +808,6 @@ mod animations {
);
});
});
});
});
}
// When a scene is de-selected, remove any outdated animation options

Loading…
Cancel
Save