-
|
I've been struggling a bit with this and figured I may be going about things the wrong way. I'm trying to write some serialize helper functions and macros that will serialize the component along with the entity given a specific component type, as well as a marker component indicating whether the entity should be serialized. I've deleted most of the extraneous code: pub trait SerializeComponents<'a, E, C, CQ, M>
where
M: Component,
C: Component + WorldQuery + Serialize + Clone,
{
fn serialize<S>(
&self,
query: Query<(Entity, C), With<M>>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut serseq = serializer.serialize_seq(Some(count))?;
query.iter().map(|(ent, comp)| {
let ent_comp_tuple: (Entity, C) = (ent, comp);
});
serseq.end()
}
}This results in the error: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You likely want to remove the Explanation of what happened: queries over some |
Beta Was this translation helpful? Give feedback.
You likely want to remove the
C: WorldQuerybound and useQuery<(Entity, &C), With<M>>instead of your current query.Explanation of what happened: queries over some
WorldQueryCwill yield values of type<C as WorldQuery>::Item<'w>. For example ifCwas&mut T(for someT: Component) then the values yielded will be of typebevy::ecs::change_detection::Mut<'w, T>. For&Chowever the query item is also&C, so there shouldn't be problems. Also, generally aComponentCis not a validWorldQuery, but&Cand&mut Care, hence why I suggested you to remove theC: WorldQuerybound.