use nightshade_ecs::Entity;
use crate::ecs::transform::components::LocalTransform;
use crate::ecs::world::World;
use super::components::PrefabComponents;
pub type PrefabEntitySpawn = fn(&mut World, Entity, &PrefabComponents, LocalTransform);
#[derive(Default)]
pub struct PrefabCapabilityHooks {
pub entity_spawn: Vec<PrefabEntitySpawn>,
}
pub fn run_entity_spawn(
world: &mut World,
entity: Entity,
components: &PrefabComponents,
local_transform: LocalTransform,
) {
let hooks = std::mem::take(&mut world.res_mut::<PrefabCapabilityHooks>().entity_spawn);
for hook in &hooks {
hook(world, entity, components, local_transform);
}
world.res_mut::<PrefabCapabilityHooks>().entity_spawn = hooks;
}