//! Particle spawn compute pass.

use super::buffers::GpuPhysicsBuffers;
use super::emitter_gpu::EmitterPool;

pub struct SpawnPass {
    _placeholder: (),
}

impl SpawnPass {
    pub fn new(_device: &wgpu::Device) -> Self {
        Self { _placeholder: () }
    }

    pub fn dispatch(
        &mut self,
        _device: &wgpu::Device,
        _queue: &wgpu::Queue,
        _encoder: &mut wgpu::CommandEncoder,
        _buffers: &GpuPhysicsBuffers,
        emitter_pool: &mut EmitterPool,
        dt: f32,
    ) {
        // Accumulate time for each emitter and determine spawn counts.
        for emitter in emitter_pool.active_emitters_mut() {
            if !emitter.active {
                continue;
            }
            emitter.time_accumulator += dt;
            let spawn_interval = 1.0 / emitter.descriptor.spawn.rate_per_sec.max(0.001);
            while emitter.time_accumulator >= spawn_interval {
                emitter.time_accumulator -= spawn_interval;
                emitter.particles_spawned += 1;
            }
        }
        // GPU spawn dispatch would happen here using the spawn shader.
        // For now, CPU-side particle initialization via buffer writes.
    }
}
