package de.frajul.particlelab.entities.particles;

import android.content.Context;

import de.frajul.particlelab.entities.textures.TextureLoader;
import de.frajul.particlelab.rendering.Timer;

/**
 * Created by Julian on 02.08.2016.
 */
public class ParticleSystem {

    public static final float TRANSFER_VALUE = 0.002f;
    public final ParticleEffect explosion;
    public final ParticleEffect firework;
    private ParticleEffect[] effects;

    private TextureLoader textureLoader;

    public ParticleSystem(Context context) throws Exception {
        this.textureLoader = new TextureLoader(context);
        ParticleReader reader = new ParticleReader(context);
        explosion = reader.read("explosion.pe");
        firework = reader.read("firework.pe");

        effects = new ParticleEffect[]{explosion, firework};
    }

    public void update(Timer timer) {
        for (ParticleEffect effect : effects)
            effect.update(timer);
    }

    public void loadTextures() throws Exception {
        for (ParticleEffect effect : effects)
            effect.setTexture(textureLoader.loadTexture(effect.getTextureName()));
    }

    public ParticleEffect[] getEffects() {
        return effects;
    }
}
