We should use custom UUID component instead of Entity id
For serialization we should check manually if entity has specific components (and, well, iterate through all of them)
(because of 2) We should manually decide what components should be registered and how components should be serialized/deserialized
To iterate over all alive entities we must use entities_for_debugging(). It marked "not very fast, so should only be used for debugging", but well I don't see any other alternatives for serialization
My big question is: how elegantly implement UUIDCollisionResolver? I mean, UUIDGenerator automatically attaches UUID component for every new Entity, and when we try to deserialize some entities from external file here is high probability that UUIDs of that entities are already taken
Also, some components can store UUID in themselves, so UUID must be replaced with a correct one too
To be more specific, lets say we have such components:
Create an DeserializationStarted and DeserializationEnded events
When DeserializationStarted emits, UUIDGenerator will stop automatically attach new UUIDs + all new entities will be stored in temporal buffer
When DeserializationEnded emits, temporal buffer should be merged with "global id buffer" with collision resolving step (we can use std::map which will map UUID to the "corrected UUID" (they are the same if here is no collisions))
I'm trying to integrate cereal serialization library with entityx
Also I have read https://github.com/alecthomas/entityx/issues/117, https://github.com/alecthomas/entityx/issues/14 and https://github.com/alecthomas/entityx/issues/25
I got four basic ideas:
My big question is: how elegantly implement UUIDCollisionResolver? I mean, UUIDGenerator automatically attaches UUID component for every new Entity, and when we try to deserialize some entities from external file here is high probability that UUIDs of that entities are already taken
Also, some components can store UUID in themselves, so UUID must be replaced with a correct one too
To be more specific, lets say we have such components: