-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - Add get_entity to Commands #5854
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig it!
Could you mention in the doc that it doesn't ensure the command will succeed, as the entity may not exist anymore by the time the command is executed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Francois, but other than that it's a nice and simple addition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestions for clarity.
Co-authored-by: Jerome Humbert <[email protected]>
Co-authored-by: Jerome Humbert <[email protected]>
bors r+ |
# Objective - Fixes #5850 ## Solution - As described in the issue, added a `get_entity` method on `Commands` that returns an `Option<EntityCommands>` ## Changelog - Added the new method with a simple doc test - I have re-used `get_entity` in `entity`, similarly to how `get_single` is used in `single` while additionally preserving the error message - Add `#[inline]` to both functions Entities that have commands queued to despawn system will still return commands when `get_entity` is called but that is representative of the fact that the entity is still around until those commands are flushed. A potential `contains_entity` could also be added in this PR if desired, that would effectively be replacing Entities.contains but may be more discoverable if this is a common use case. Co-authored-by: Carter Anderson <[email protected]>
Pull request successfully merged into main. Build succeeded: |
# Objective - Fixes bevyengine#5850 ## Solution - As described in the issue, added a `get_entity` method on `Commands` that returns an `Option<EntityCommands>` ## Changelog - Added the new method with a simple doc test - I have re-used `get_entity` in `entity`, similarly to how `get_single` is used in `single` while additionally preserving the error message - Add `#[inline]` to both functions Entities that have commands queued to despawn system will still return commands when `get_entity` is called but that is representative of the fact that the entity is still around until those commands are flushed. A potential `contains_entity` could also be added in this PR if desired, that would effectively be replacing Entities.contains but may be more discoverable if this is a common use case. Co-authored-by: Carter Anderson <[email protected]>
# Objective - Fixes bevyengine#5850 ## Solution - As described in the issue, added a `get_entity` method on `Commands` that returns an `Option<EntityCommands>` ## Changelog - Added the new method with a simple doc test - I have re-used `get_entity` in `entity`, similarly to how `get_single` is used in `single` while additionally preserving the error message - Add `#[inline]` to both functions Entities that have commands queued to despawn system will still return commands when `get_entity` is called but that is representative of the fact that the entity is still around until those commands are flushed. A potential `contains_entity` could also be added in this PR if desired, that would effectively be replacing Entities.contains but may be more discoverable if this is a common use case. Co-authored-by: Carter Anderson <[email protected]>
Objective
Commands
#5850Solution
get_entity
method onCommands
that returns anOption<EntityCommands>
Changelog
get_entity
inentity
, similarly to howget_single
is used insingle
while additionally preserving the error message#[inline]
to both functionsEntities that have commands queued to despawn system will still return commands when
get_entity
is called but that is representative of the fact that the entity is still around until those commands are flushed.A potential
contains_entity
could also be added in this PR if desired, that would effectively be replacing Entities.contains but may be more discoverable if this is a common use case.