bevy/crates/bevy_ecs/src
James O'Brien f9853cbbc2 Add get_entity to Commands (#5854)
# 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 <mcanders1@gmail.com>
2022-09-01 22:06:46 +00:00
..
entity Make most Entity methods const (#5688) 2022-08-30 03:16:22 +00:00
query Add documentation to QueryCombinationIter (#5739) 2022-08-30 00:39:17 +00:00
schedule Remove an outdated workaround for impl Trait (#5659) 2022-08-16 23:40:24 +00:00
storage Remove insert_resource_with_id (#5608) 2022-08-30 20:32:15 +00:00
system Add get_entity to Commands (#5854) 2022-09-01 22:06:46 +00:00
world Remove insert_resource_with_id (#5608) 2022-08-30 20:32:15 +00:00
archetype.rs Fix various typos (#5417) 2022-07-21 20:46:54 +00:00
bundle.rs add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
change_detection.rs remove ReflectMut in favor of Mut<dyn Reflect> (#5630) 2022-08-09 16:19:34 +00:00
component.rs add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
event.rs Warning message for missing events (#5730) 2022-08-30 02:23:04 +00:00
lib.rs Add a module for common system chain/pipe adapters (#5776) 2022-08-30 00:17:20 +00:00
reflect.rs remove ReflectMut in favor of Mut<dyn Reflect> (#5630) 2022-08-09 16:19:34 +00:00