-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Remame Entity::new(id: u32)
to from_raw
#3108
Comments
This is currently used in scenes and in transforms. Transforms could probably be rework to not use it, but it seems harder for scenes. |
I use this method to initialize a known size let mut entities = vec![Entity::new(0); n]; that is then overwritten by index with valid entities for all indices, but in random order. This pattern is often used for building indices or sorting parallel vectors, where one vector is sorted and others are permuted in the same way. I'd prefer to use |
Maybe related to #3029 which introduce the notion of an invalid entity |
I use it externally when deriving |
Maybe rename |
I like this, and think this is how we should proceed. A better name, plus clear docs should resolve the confusion. The feedback from the users about how this is used is very useful; @Davier's use case in particular seems very challenging to eliminate. |
Entity::new(id: u32)
privateEntity::new(id: u32)
to from_raw
# Objective - Rename `Entity::new(id: u32)` to `Entity::from_raw(id: u32)`. - Add further documentation. - fixes bevyengine#3108 ## Solution - Renamed `Entity::new(id: u32)` to `Entity::from_raw(id: u32)`. - Docs extended. I derived the examples from the discussion of issue bevyengine#3108 . The [first case](bevyengine#3108 (comment)) mentioned in the linked issue is quite obvious but the [second one](bevyengine#3108 (comment)) probably needs further explanation. Co-authored-by: r4gus <david@thesugar.de>
What problem does this solve or what need does it fill?
Users are commonly confused by this method, and try and fail to use it for synchronization tasks.
What solution would you like?
Make this method
pub(crate)
.What alternative(s) have you considered?
Better document if and when it can be correctly used.
Additional context
Generally the advice when attempting to synchronize the ECS is to insert a secondary identifier as a component, rather than attempting to ensure that
Entity
lines up between the instances.I have not seen any valid external use of this API, but if they exist, we should attempt to create workarounds or focus on the documentation path.
The text was updated successfully, but these errors were encountered: