You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow for issuing queries using DynamicBundle. We currently have to use a separate struct with #[derive(Query)]. It would be nice if we could query a bundle, for example:
use hecs::{World};letmut world = World::new();letmut target_world = World::new();#[derive(Bundle,DynamicBundleClone,BundleQuery)]structMyBundle{integer:i32,float:f32,}let bundle_to_spawn = MyBundle{integer:1,float:2.0};let spawned = world.spawn(bundle);for(entity, bundle)in world.query_mut::<MyBundleQuery>(){assert_eq!(entity, spawned);assert_eq!(bundle, bundle_to_spawn);
target_world.spawn(bundle.clone())}
Presumably, MyBundleQuery is generated by the #[derive(BundleQuery)]. This is necessary because each field needs to be wrapped in a reference to work as a query type, so we can't use the original MyBundle.
The text was updated successfully, but these errors were encountered:
This has come up a few times before. The tricky part is that you might reasonably want either shared or unique references for each component of a bundle, so a clean general-purpose solution becomes complex. You could bodge something ugly but serviceable pretty easy with a declarative macro though, yeah.
Allow for issuing queries using DynamicBundle. We currently have to use a separate struct with
#[derive(Query)]
. It would be nice if we could query a bundle, for example:Presumably,
MyBundleQuery
is generated by the#[derive(BundleQuery)]
. This is necessary because each field needs to be wrapped in a reference to work as a query type, so we can't use the originalMyBundle
.The text was updated successfully, but these errors were encountered: