package de.frajul.particlelab.entities.particles;

import de.frajul.particlelab.entities.particles.attributes.attributeValues.Options;
import de.frajul.particlelab.entities.particles.attributes.attributeValues.Range;
import de.frajul.particlelab.entities.particles.attributes.attributeValues.SpawnShape;
import de.frajul.particlelab.entities.particles.attributes.attributeValues.Timeline;
import de.frajul.particlelab.entities.particles.attributes.attributeValues.TimelineRange;
import de.frajul.particlelab.entities.particles.attributes.attributeValues.TintTimeline;
import de.frajul.particlelab.entities.textures.Texture;
import de.frajul.particlelab.rendering.Timer;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by Julian on 05.08.2016.
 */
public class ParticleEffect {

    private TimelineRange life;
    //Particle Timeline
    private TimelineRange scale;
    private TimelineRange velocity;
    private TimelineRange angle;
    private TimelineRange rotation;
    private Timeline transparency;
    private TintTimeline tint;

    //Source Timeline
    private Range delay;
    private Range duration;
    private TimelineRange emission;
    private Range xOffset;
    private Range yOffset;
    private SpawnShape.Shape spawnShape;
    private TimelineRange spawnWidth;
    private TimelineRange spawnHeight;
    private TimelineRange wind;
    private TimelineRange gravity;

    private Options options;
    private Texture texture;
    private String textureName;

    private Random random;
    private List<ParticleSource> sources = new ArrayList<>();

    public ParticleEffect() {
        this.random = new Random();
    }

    public void update(Timer timer) {
        for (ParticleSource source : sources)
            source.update(timer);
    }

    public ParticleData createParticleData(){
        return new ParticleData(life.getRange(), scale, velocity, angle, rotation, transparency, tint);
    }

    public Random getRandom() {
        return random;
    }

    public void addSource(ParticleSource source) {
        sources.add(source);
    }

    public void setDelay(Range delay) {
        this.delay = delay;
    }

    public void setDuration(Range duration) {
        this.duration = duration;
    }

    public void setEmission(TimelineRange emission) {
        this.emission = emission;
    }

    public void setLife(TimelineRange life) {
        this.life = life;
    }

    public void setxOffset(Range xOffset) {
        this.xOffset = xOffset;
    }

    public void setyOffset(Range yOffset) {
        this.yOffset = yOffset;
    }

    public void setSpawnShape(SpawnShape.Shape spawnShape) {
        this.spawnShape = spawnShape;
    }

    public void setSpawnWidth(TimelineRange spawnWidth) {
        this.spawnWidth = spawnWidth;
    }

    public void setSpawnHeight(TimelineRange spawnHeight) {
        this.spawnHeight = spawnHeight;
    }

    public void setScale(TimelineRange scale) {
        this.scale = scale;
    }

    public void setVelocity(TimelineRange velocity) {
        this.velocity = velocity;
    }

    public void setAngle(TimelineRange angle) {
        this.angle = angle;
    }

    public void setRotation(TimelineRange rotation) {
        this.rotation = rotation;
    }

    public void setWind(TimelineRange wind) {
        this.wind = wind;
    }

    public void setGravity(TimelineRange gravity) {
        this.gravity = gravity;
    }

    public void setTint(TintTimeline tint) {
        this.tint = tint;
    }

    public void setTransparency(Timeline transparency) {
        this.transparency = transparency;
    }

    public Timeline getTransparency() {
        return transparency;
    }

    public TintTimeline getTint() {
        return tint;
    }

    public void setOptions(Options options) {
        this.options = options;
    }

    public void setTexture(Texture texture) {
        this.texture = texture;
    }

    public void setTextureName(String textureName) {
        this.textureName = textureName;
    }

    public String getTextureName() {
        return textureName;
    }

    public Texture getTexture() {
        return texture;
    }

    public Range getDelay() {
        return delay;
    }

    public Range getDuration() {
        return duration;
    }

    public TimelineRange getEmission() {
        return emission;
    }

    public Options getOptions() {
        return options;
    }

    public TimelineRange getWind() {
        return wind;
    }

    public TimelineRange getGravity() {
        return gravity;
    }

    public Range getxOffset() {
        return xOffset;
    }

    public Range getyOffset() {
        return yOffset;
    }

    public List<ParticleSource> getSources() {
        return sources;
    }

    public TimelineRange getLife() {
        return life;
    }

    public SpawnShape.Shape getSpawnShape() {
        return spawnShape;
    }

    public TimelineRange getSpawnHeight() {
        return spawnHeight;
    }

    public TimelineRange getSpawnWidth() {
        return spawnWidth;
    }
}

