package ecs.systems;

import ecs.components.Audio;
import ecs.core.Entity;
import ecs.core.System;
import res.audio.IAudioMixer;
import res.rom.Rom;

class AudioSystem extends System {
	var mixer:IAudioMixer;
	var rom:Rom;

	public function new(mixer:IAudioMixer, rom:Rom) {
		super(Audio);

		this.mixer = mixer;
		this.rom = rom;
	}

	override function updateEntity(entity:Entity, dt:Float) {
		mixer.play(rom.audioBuffers[entity.get(Audio).id]);
		engine.remove(entity);
	}
}
