c661027d19
Replace scaffold placeholders with full skill content: - bevy-0.19: ECS cheat sheet, critical traps table, architecture guide, and 7 reference files - bevy-upgrade: version migration workflow, transition references for 0.15→0.19, and 3 per-bump reference files
2.9 KiB
2.9 KiB
0.15 → 0.16 → 0.17
The 0.16 transition restructured hierarchy and spawning; 0.17 was comparatively quiet. Both are covered here. For changes not listed, consult the official guides: https://bevy.org/learn/migration-guides/0-15-to-0-16/ and .../0-16-to-0-17/.
Renames & removals (mechanical)
| Old (≤0.15) | New (0.16+) | Notes |
|---|---|---|
Parent component |
ChildOf(pub Entity) |
Lives on the child; entities with ChildOf are children |
*parent (Deref to Entity) |
child_of.parent() |
Deref removed |
despawn_recursive() |
despawn() |
despawn() is now recursive by default |
despawn_descendants() |
despawn_related::<Children>() |
|
#[derive(Bundle)] |
spawn tuples + #[require(...)] |
Bundles removed as a user-facing pattern |
StateScoped(state) |
DespawnOnExit(state) / DespawnOnEnter(state) |
|
parent_entity() (child spawner) |
target_entity() |
API shape changes
- Hierarchy is relationship-based:
ChildOfimplementsRelationship,ChildrenimplementsRelationshipTarget; they sync automatically via hooks. Delete any manualChildrenbookkeeping — it now fights the engine. - Spawning children:
commands.spawn((Comp, ChildOf(parent)))works directly;with_children(|spawner| ...)remains.add_child/add_children/insert_childrenattach existing entities. Childreniteration yieldsEntityviaIntoIterator:for child in &children. Ports ofchildren.iter().copied()compile but are noise — simplify during cleanup.- Required components replace bundles:
#[require(Transform, Visibility)]on a marker pulls in dependencies at spawn. When porting aBundlestruct, its fields usually become either a spawn tuple at call sites or#[require(...)]on the primary component. - Query relationship extensions appear:
query.related::<ChildOf>(entity),query.relationship_sources::<Children>(entity).
Semantic shifts (audit, don't just compile)
despawn()is recursive. Code that relied ondespawn()orphaning children (intentionally detaching them) now destroys them. If detach-then-despawn was the intent,detach_all_children()first (name as of 0.18;clear_children()in 0.16–0.17).- Adding
ChildOfhas side effects: parent'sChildrenupdates immediately via hooks, and lifecycle observers onChildrenfire. Ordering assumptions around manual parent updates are void.
Porting checklist
grep -rn "Parent\b"— replace withChildOf, fix accessors to.parent().grep -rn "despawn_recursive\|despawn_descendants"— rename; then audit remaining plaindespawn()calls for the orphaning assumption.grep -rn "derive(Bundle)"— convert to tuples/#[require].grep -rn "StateScoped"— replace withDespawnOnExit/DespawnOnEnter.- Remove manual child-list maintenance (observers/systems pushing into
Children).