🤖 Flesh out bevy-0.19 and bevy-upgrade skills from research
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
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# 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**: `ChildOf` implements `Relationship`, `Children` implements `RelationshipTarget`; they sync automatically via hooks. Delete any manual `Children` bookkeeping — it now fights the engine.
|
||||
- **Spawning children**: `commands.spawn((Comp, ChildOf(parent)))` works directly; `with_children(|spawner| ...)` remains. `add_child` / `add_children` / `insert_children` attach existing entities.
|
||||
- **`Children` iteration** yields `Entity` via `IntoIterator`: `for child in &children`. Ports of `children.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 a `Bundle` struct, 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 on `despawn()` 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 `ChildOf` has side effects**: parent's `Children` updates immediately via hooks, and lifecycle observers on `Children` fire. Ordering assumptions around manual parent updates are void.
|
||||
|
||||
## Porting checklist
|
||||
|
||||
1. `grep -rn "Parent\b"` — replace with `ChildOf`, fix accessors to `.parent()`.
|
||||
2. `grep -rn "despawn_recursive\|despawn_descendants"` — rename; then audit remaining plain `despawn()` calls for the orphaning assumption.
|
||||
3. `grep -rn "derive(Bundle)"` — convert to tuples/`#[require]`.
|
||||
4. `grep -rn "StateScoped"` — replace with `DespawnOnExit`/`DespawnOnEnter`.
|
||||
5. Remove manual child-list maintenance (observers/systems pushing into `Children`).
|
||||
@@ -0,0 +1,57 @@
|
||||
# 0.17 → 0.18
|
||||
|
||||
The largest recent transition. Its centerpiece — the Event/Message split — is architectural, not just a rename. Official guide for the long tail: `https://bevy.org/learn/migration-guides/0-17-to-0-18/`.
|
||||
|
||||
## The Event/Message split
|
||||
|
||||
The old buffered event system was split in two:
|
||||
|
||||
| Old (≤0.17) | New (0.18) |
|
||||
|-------------|-----------|
|
||||
| `#[derive(Event)]` (buffered use) | `#[derive(Message)]` |
|
||||
| `EventWriter<T>` / `.send(e)` | `MessageWriter<T>` / `.write(m)` |
|
||||
| `EventReader<T>` | `MessageReader<T>` |
|
||||
| `Events<T>` | `Messages<T>` |
|
||||
| `on_event::<T>()` run condition | `on_message::<T>()` |
|
||||
|
||||
`Event` still exists but now means **observer-events only** (`commands.trigger()` + `On<E>` observers, immediate push). This is the transition's biggest trap: a type ported to `#[derive(Event)]` and written with a `MessageWriter` won't compile, but a type left as `Event` with a forgotten reader silently does nothing.
|
||||
|
||||
Port rule: every buffered event → `Message`. Only convert to `Event`+observer deliberately, during post-migration cleanup, where immediate reaction is actually wanted.
|
||||
|
||||
New in 0.18: `#[derive(EntityEvent)]` with `#[event_target]` for entity-targeted events, optionally `#[entity_event(propagate)]` to bubble up `ChildOf`.
|
||||
|
||||
## Renames & moves (mechanical)
|
||||
|
||||
| Old | New |
|
||||
|-----|-----|
|
||||
| `remove_child` / `remove_children` / `clear_children` | `detach_child` / `detach_children` / `detach_all_children` |
|
||||
| `bevy::render::render_resource::ShaderRef` | `bevy::shader::ShaderRef` |
|
||||
| `WinitPlugin::<WakeUp>` | `WinitPlugin` (no longer generic) |
|
||||
| `AmbientLight` (single type) | `GlobalAmbientLight` **resource** + `AmbientLight` **camera component** |
|
||||
| `Camera.target` field | `RenderTarget` required component |
|
||||
| `GltfPlugin` `use_model_forward_direction` | `convert_coordinates` + `rotate_scene_entity` / `rotate_meshes` flags |
|
||||
|
||||
## API shape changes
|
||||
|
||||
- **Fallible systems**: systems may return `Result` (= `Result<(), BevyError>`); errors log and the system retries next tick. Adopt during the bump wherever it deletes `unwrap()`s cheaply; systematically during cleanup.
|
||||
- **Mesh accessors** became `try_*` returning `Result<_, MeshAccessError>`.
|
||||
- **`MaterialPlugin` fields** `prepass_enabled` / `shadows_enabled` became `Material` trait methods.
|
||||
- **`LoadContext::path()`** returns `AssetPath`, not `Path`; image `reinterpret_*` methods return `Result`.
|
||||
- **Immutable components**: `#[component(immutable)]` available.
|
||||
- **Input feature gates**: `mouse`, `keyboard`, `gamepad`, `touch`, `gestures` are now cargo features. Default-on, but builds with `default-features = false` must list them — otherwise input silently stops arriving.
|
||||
|
||||
## Semantic shifts (audit, don't just compile)
|
||||
|
||||
- **`NextState::set()` same-state transitions fire.** `set(Playing)` while in `Playing` now triggers `OnExit(Playing)` + `OnEnter(Playing)` (previously a no-op). One-time setup in `OnEnter` (spawn camera, load level) re-runs. Audit every `next_state.set(...)` reachable while already in that state; use `set_if_neq()` where the old behavior is wanted.
|
||||
- **Material shader bind groups**: material bindings are `@group(3)`; `@group(2)` is the mesh storage buffer. Old custom shaders using `@group(2)` fail with `Storage class Storage doesn't match the shader Uniform`. Update all `.wgsl` material shaders.
|
||||
- **`MouseMotion`, `MouseWheel` and other input streams are Messages now** — readers must be `MessageReader`.
|
||||
|
||||
## Porting checklist
|
||||
|
||||
1. `grep -rn "EventWriter\|EventReader\|on_event\|Events<"` — rename to Message equivalents; `.send(` → `.write(`.
|
||||
2. `grep -rn "derive(Event)"` — decide per type: buffered (→ `Message`) or observed (stays `Event`, needs a trigger + observer).
|
||||
3. `grep -rn "remove_child\|clear_children"` — rename to `detach_*`.
|
||||
4. `grep -rn "next_state.set\|NextState"` — audit same-state re-fire.
|
||||
5. `grep -rn "@group(2)" --include=*.wgsl` — move material bindings to group 3.
|
||||
6. `grep -rn "AmbientLight"` — split into resource vs camera component usage.
|
||||
7. Check `Cargo.toml` for `default-features = false` on bevy → add input features.
|
||||
@@ -0,0 +1,36 @@
|
||||
# 0.18 → 0.19
|
||||
|
||||
Smaller than 0.17→0.18 but with one deep semantic change: resources became components. Official guide for the long tail: `https://bevy.org/learn/migration-guides/0-18-to-0-19/`.
|
||||
|
||||
## Renames & moves (mechanical)
|
||||
|
||||
| Old (0.18) | New (0.19) |
|
||||
|------------|-----------|
|
||||
| `Scene` / `SceneRoot` | `WorldAsset` / `WorldAssetRoot` |
|
||||
| `AssetPath::resolve(&str)` / `resolve_embed(&str)` | `resolve_str()` / `resolve_embed_str()` (`resolve()`/`resolve_embed()` now take `&AssetPath`) |
|
||||
| `Hdr` in `bevy_render` | `bevy_camera` |
|
||||
| `Camera` screen-space specular transmission fields | `ScreenSpaceTransmission` component |
|
||||
|
||||
## API shape changes
|
||||
|
||||
- **`Assets::get_mut`** returns `AssetMut<A>` (mutation-tracked), not `&mut A`. Deref for access; code storing the `&mut A` needs restructuring.
|
||||
- **`Ref<T>.clone()`** returns `Ref<T>`, not the inner value. Old code relying on clone-through must use `ref.deref().clone()`.
|
||||
- **GLTF material loading** returns `GltfMaterial`; request a `StandardMaterial` with the `#Material0/std` label suffix.
|
||||
- **`EntityComponentsTrigger`** gained archetype fields — exhaustive destructuring breaks; add `..`:
|
||||
`let EntityComponentsTrigger { components, .. } = e.trigger();`
|
||||
|
||||
## Semantic shifts (audit, don't just compile)
|
||||
|
||||
- **Resources are components on abstract entities.** Consequences:
|
||||
- `Query<Entity>` and other very broad queries now match resource entities. Any "iterate all entities" logic (cleanup sweeps, entity counts, serialization, debug overlays) silently includes resources — filter with `Without<IsResource>`.
|
||||
- A type can no longer derive both `Component` and `Resource`. Split such types or pick one role.
|
||||
- **Scene rename is semantic-adjacent**: `WorldAsset` naming reflects the same data model, but grep for the old names in strings/reflection paths, not just types.
|
||||
|
||||
## Porting checklist
|
||||
|
||||
1. `grep -rn "SceneRoot\|Scene>" ` — rename to `WorldAssetRoot`/`WorldAsset`.
|
||||
2. `grep -rn "Query<Entity[,>]"` and other broad queries — add `Without<IsResource>` where resources must not appear.
|
||||
3. `grep -rn "derive(Component" | grep "Resource"` — find dual-derive types; split them.
|
||||
4. `grep -rn "get_mut" ` on `Assets<...>` — adapt to `AssetMut`.
|
||||
5. `grep -rn "EntityComponentsTrigger {"` — add `..` to destructuring.
|
||||
6. GLTF material handles — append `/std` labels where `StandardMaterial` is expected.
|
||||
Reference in New Issue
Block a user