mirror of
https://github.com/bevyengine/bevy
synced 2025-01-04 17:28:56 +00:00
b2529bf100
# Objective Often there are reasons to insert some components (e.g. Transform) separately from the rest of a bundle (e.g. PbrBundle). However `insert` overwrites existing components, making this difficult. See also issue #14397 Fixes #2054. ## Solution This PR adds the method `insert_if_new` to EntityMut and Commands, which is the same as `insert` except that the old component is kept in case of conflicts. It also renames some internal enums (from `ComponentStatus::Mutated` to `Existing`), to reflect the possible change in meaning. ## Testing *Did you test these changes? If so, how?* Added basic unit tests; used the new behavior in my project. *Are there any parts that need more testing?* There should be a test that the change time isn't set if a component is not overwritten; I wasn't sure how to write a test for that case. *How can other people (reviewers) test your changes? Is there anything specific they need to know?* `cargo test` in the bevy_ecs project. *If relevant, what platforms did you test these changes on, and are there any important ones you can't test?* Only tested on Windows, but it doesn't touch anything platform-specific. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com> |
||
---|---|---|
.. | ||
blob_vec.rs | ||
mod.rs | ||
resource.rs | ||
sparse_set.rs | ||
table.rs |