bevy/crates/bevy_ecs/src
Joseph df2ba09989
Restore support for running fn EntityCommands on entities that might be despawned (#11107)
# Objective

In #9604 we removed the ability to define an `EntityCommand` as
`fn(Entity, &mut World)`. However I have since realized that `fn(Entity,
&mut World)` is an incredibly expressive and powerful way to define a
command for an entity that may or may not exist (`fn(EntityWorldMut)`
only works on entities that are alive).

## Solution

Support `EntityCommand`s in the style of `fn(Entity, &mut World)`, as
well as `fn(EntityWorldMut)`. Use a marker generic on the
`EntityCommand` trait to allow multiple impls.

The second commit in this PR replaces all of the internal command
definitions with ones using `fn` definitions. This is mostly just to
show off how expressive this style of command is -- we can revert this
commit if we'd rather avoid breaking changes.

---

## Changelog

Re-added support for expressively defining an `EntityCommand` as a
function that takes `Entity, &mut World`.

## Migration Guide

All `Command` types in `bevy_ecs`, such as `Spawn`, `SpawnBatch`,
`Insert`, etc., have been made private. Use the equivalent methods on
`Commands` or `EntityCommands` instead.
2024-01-08 22:32:28 +00:00
..
entity Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
query Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
reflect Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
schedule StateTransitionEvent (#11089) 2024-01-08 22:27:00 +00:00
storage Fix integer overflow in BlobVec::reserve_exact (#11234) 2024-01-06 17:31:01 +00:00
system Restore support for running fn EntityCommands on entities that might be despawned (#11107) 2024-01-08 22:32:28 +00:00
world Fixed Typo in the description of EntityMut (#11103) 2024-01-01 16:51:25 +00:00
archetype.rs Rename ArchetypeEntity::entity into ArchetypeEntity::id (#11118) 2024-01-01 16:12:24 +00:00
bundle.rs Allow #[derive(Bundle)] on tuple structs (take 3) (#10561) 2023-11-21 01:09:16 +00:00
change_detection.rs Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
component.rs Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
event.rs Explain EventWriter limits concurrency (#11063) 2023-12-24 17:45:21 +00:00
lib.rs StateTransitionEvent (#11089) 2024-01-08 22:27:00 +00:00
removal_detection.rs Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00