-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to clone World? With use case. #333
Comments
You can (ab)use the serialization mechanism for cloning by serializing and then deserializing. Admittedly, it has some drawbacks w.r.t. efficiency and determinism, but it should work right now. Alternatively, we could implement something like the |
Thanks @adamreichold. :) That's exactly what I ended up doing. I actually realised I'd probably want to serialise/deserialise regardless, as some of the components have "editable" versions, and I'll want the non-editable ones for play testing. For example, editable versions of components have In other words, would be very cool if Off-topic: what would be a good serde format for this sort of thing? |
My personal first choice would be |
It's worth noting that the public API is already powerful enough for this to be implemented downstream, even column-oriented.
It's also possible to use non-serde serialization, though it may take a bit of work. The out-of-the-box serde serialization code should serve as a good example; it uses only public hecs APIs. |
I think this is true for the component data but that the entity allocator state is not exposed leading to the restricted determinism as discussed in #332? |
Thanks for your advice guys, and thanks a lot for your work on hecs! I'm loving it, and it's a key crate in our game, next to serde, ash and rhai. I'll stick with serde_json for prototyping as I'm very far away from performance being a concern. |
I'm making a game editor and game with hecs. All of the game state is currently stored in a hecs
World
. The idea is the game designer sets up the initialWorld
state by adding entities and components, then plays the game (prototype) in the same editor app. At that point I need to clone theWorld
somehow.Its components contain
Entity
values (dialogue graph etc), so I can't just spawn and clone individual components. As I'm writing this I'm seeing thatinsert
allows you to assign components to a specificEntity
, so I guess I could use that? Seems inefficient though.The text was updated successfully, but these errors were encountered: