use specs::{Component, World, WorldExt};
use std::any;
#[derive(Copy, Clone)]
pub(crate) struct ComponentVtable {
name: &'static str,
register: fn(world: &mut World),
}
impl ComponentVtable {
pub fn for_type<T>() -> Self
where
T: Component,
T::Storage: Default,
{
ComponentVtable {
name: any::type_name::<T>(),
register: |world| {
world.register::<T>();
},
}
}
pub fn name(&self) -> &'static str { self.name }
pub(crate) fn register(&self, world: &mut World) { (self.register)(world); }
}