-
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
Custom serialization for Entity
#386
Comments
|
Using specifically
Pretty much! Having two Entity types and having to convert between them in basically every single piece of gameplay code is really rough. It's pretty easy to define custom serialization for |
Summarizing chat discussion:
|
This issue is rough spitballing for how hecs might allow users to define how
Entity
gets serialized/deserialized.hecs has been fantastic for our game and we've had a good serialization solution for a long time. One of the warts in our integration, however, is that we have two versions of the
Entity
type in order to support a custom implementation ofSerialize
andDeserialize
. All of our components use our wrapped version and they automatically get remapped to integers or strings when appropriate during serialization.In some places, we're able to easily wrap the hecs APIs to only return our custom
Entity
type, buthecs::Entity
usually ends up leaking out. We call that typeEphemeralEntity
to emphasize that it's meant to be for non-serialized data, but I'd rather not have that type at all!One option is for us to keep a small fork of hecs where we change the implementation of
Serialize
andDeserialize
onEntity
to go through our remapping process. It probably wouldn't be a very big patch, but then we're out of "userspace" hecs which is kind of lame.A large hammer of an API would be for hecs to expose a global that a user could override in order to implement
Serialize
andDeserialize
. Maybe that'd be in the form of a trait object that mirror's#[serde(with = ...)]
and useserased_serde
.I'm down for any other options in this space that lead to us being able to delete the wrapper around
hecs::Entity
in our codebase. 😅The text was updated successfully, but these errors were encountered: