|
1 | 1 | use core::marker::PhantomData; |
2 | 2 |
|
3 | 3 | use bevy::ecs::{ |
4 | | - component::{ComponentHooks, ComponentId, Immutable, StorageType}, |
| 4 | + component::{ComponentHooks, HookContext, Immutable, StorageType}, |
5 | 5 | prelude::*, |
6 | 6 | world::DeferredWorld, |
7 | 7 | }; |
@@ -51,14 +51,10 @@ impl<B: Bundle> Component for WithChild<B> { |
51 | 51 | /// A hook that runs whenever [`WithChild`] is added to an entity. |
52 | 52 | /// |
53 | 53 | /// Generates a [`WithChildCommand`]. |
54 | | -fn with_child_hook<B: Bundle>( |
55 | | - mut world: DeferredWorld<'_>, |
56 | | - entity: Entity, |
57 | | - _component_id: ComponentId, |
58 | | -) { |
| 54 | +fn with_child_hook<B: Bundle>(mut world: DeferredWorld<'_>, context: HookContext) { |
59 | 55 | // Component hooks can't perform structural changes, so we need to rely on commands. |
60 | 56 | world.commands().queue(WithChildCommand { |
61 | | - parent_entity: entity, |
| 57 | + parent_entity: context.entity, |
62 | 58 | _phantom: PhantomData::<B>, |
63 | 59 | }); |
64 | 60 | } |
@@ -160,12 +156,11 @@ impl<B: Bundle, I: IntoIterator<Item = B> + Send + Sync + 'static> Component |
160 | 156 | /// Generates a [`WithChildrenCommand`]. |
161 | 157 | fn with_children_hook<B: Bundle, I: IntoIterator<Item = B> + Send + Sync + 'static>( |
162 | 158 | mut world: DeferredWorld<'_>, |
163 | | - entity: Entity, |
164 | | - _component_id: ComponentId, |
| 159 | + context: HookContext, |
165 | 160 | ) { |
166 | 161 | // Component hooks can't perform structural changes, so we need to rely on commands. |
167 | 162 | world.commands().queue(WithChildrenCommand { |
168 | | - parent_entity: entity, |
| 163 | + parent_entity: context.entity, |
169 | 164 | _phantom: PhantomData::<(B, I)>, |
170 | 165 | }); |
171 | 166 | } |
|
0 commit comments