Simplify usage of EntityWorldMut::move_entity_from_remove
by making it a proper method
#17360
+71
−77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Fixes #17345
The "probably more safety stuff" was probably referring to the
EntityLocation
needing to be valid for the givenEntity
or something like that, but that's not necessary if we just give it the actualEntityWorldMut
.Solution
&mut self
tomove_entity_from_remove
parameters.self
.location
field of theEntityWorldMut
, which wasn't necessarily the case before.EntityWorldMut::take
passed in a mutable reference to the field, so it already worked like that.EntityWorldMut::remove_bundle
passed in a mutable reference to a local variable, which it then returned so that its caller could use it to update thelocation
field. This seems unnecessarily convoluted.EntityWorldMut::remove_bundle
no longer returns the entity's location, as it is now updated internally.unsafe
blocks to some calls that had a safety note with no block.