-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
What problem does this solve or what need does it fill?
Entity is identity for ECS.
It does not serve any other purpose than to identify a set of components in an existing World.
Persisting Entity beyond the lifetime* of a World is unsound, breaks lifetime rule, will cause misuse and problems.
*not a literal Rust lifetime, but the same concept
What solution would you like?
Remove the serde from Entity for users, it can still be used internally for scenes, because we are aware of it's flavors.
When serializing hierarchy map the identity systems (Entity -> u64).
Generate the new ids sequentially.
While Entity may be 'valid' here, because it's unique, it biases how serialization and deserialization is done.
When serializing we ignore the problem that entities will have different Entity when deserialized, because the World will be different.
When deserializing however, we need to account for it, despite having a 'valid' Entity we need to generate a new one.
If someone tries to serialize their own custom hierarchy system that uses Entity, they will be very disappointed to address a non-existing entity after deserializing.
We cannot require users to be aware of this, so we should just lock it away.
When networking use a custom NetworkId.
Additional context
Attempts of using Entity for identity over network.
Related #6194
I'm looking forward to arguments supporting both sides.