Replace init_component_info with register_component_hooks (#12244)
# Objective - Fix mismatch between the `Component` trait method and the `World` method. ## Solution - Replace init_component_info with register_component_hooks.
This commit is contained in:
parent
165c360070
commit
bacd5e873b
@ -155,9 +155,8 @@ pub trait Component: Send + Sync + 'static {
|
|||||||
/// This must be either [`TableStorage`] or [`SparseStorage`].
|
/// This must be either [`TableStorage`] or [`SparseStorage`].
|
||||||
type Storage: ComponentStorage;
|
type Storage: ComponentStorage;
|
||||||
|
|
||||||
/// Called when registering this component, allowing mutable access to it's [`ComponentInfo`].
|
/// Called when registering this component, allowing mutable access to it's [`ComponentHooks`].
|
||||||
/// This is currently used for registering hooks.
|
fn register_component_hooks(_hooks: &mut ComponentHooks) {}
|
||||||
fn init_component_info(_info: &mut ComponentInfo) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Marker type for components stored in a [`Table`](crate::storage::Table).
|
/// Marker type for components stored in a [`Table`](crate::storage::Table).
|
||||||
@ -580,7 +579,7 @@ impl Components {
|
|||||||
storages,
|
storages,
|
||||||
ComponentDescriptor::new::<T>(),
|
ComponentDescriptor::new::<T>(),
|
||||||
);
|
);
|
||||||
T::init_component_info(&mut components[index.index()]);
|
T::register_component_hooks(&mut components[index.index()].hooks);
|
||||||
index
|
index
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! This examples illustrates the different ways you can employ component lifecycle hooks
|
//! This examples illustrates the different ways you can employ component lifecycle hooks
|
||||||
|
|
||||||
use bevy::ecs::component::{ComponentInfo, TableStorage};
|
use bevy::ecs::component::{ComponentHooks, TableStorage};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@ -11,8 +11,8 @@ impl Component for MyComponent {
|
|||||||
type Storage = TableStorage;
|
type Storage = TableStorage;
|
||||||
|
|
||||||
/// Hooks can also be registered during component initialisation by
|
/// Hooks can also be registered during component initialisation by
|
||||||
/// implementing `init_component_info`
|
/// implementing `register_component_hooks`
|
||||||
fn init_component_info(_info: &mut ComponentInfo) {
|
fn register_component_hooks(_hooks: &mut ComponentHooks) {
|
||||||
// Register hooks...
|
// Register hooks...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user