Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore support for running
fn
EntityCommands
on entities that mi…
…ght 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.
- Loading branch information