Closed konceptosociala closed 1 year ago
The issue is that EntityBuilder
needs to know the size of the component, which means you need to pass it the concrete type. SerializableObject
is a trait object which does not know the concrete type, but only information about how to execute the methods of the trait on the underlying object.
What you can do is move the entity_builder.add(...)
call into the SerializableComponent trait. That way each implementation of the trait can handle insertion of its concrete type itself, where the knowledge is present.
I've implemented a plain non-hecs example in the Rust which shows how to achieve it: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1a8557ebcc67432f1c402ecaba8d8387
I'm trying to implement spawning a dynamic de-/serializable scene to a
World
like this:where say
SerializableComponent
necessarily implements bothComponent
andSerialize/Deserialize
(usingtypetag
crate)But it consequentially results into an error:
Is there a way to do it, or is this just impossible?