package speiger.src.coreengine.math.value;

import speiger.src.coreengine.math.MathUtils;

public class LiniarValue extends Value {
	final float startValue;
	final float endValue;
	boolean smooth = false;
	
	public LiniarValue(float duration, float startValue, float endValue) { 
		this(0F, duration, startValue, endValue); 
	}
	
	public LiniarValue(float start, float duration, float startValue, float endValue) {
		super(start, duration);
		this.startValue = startValue;
		this.endValue = endValue;
	}
	
	public LiniarValue setSmooth() {
		smooth = true;
		return this;
	}
	
	public LiniarValue setSmooth(boolean smooth) {
		this.smooth = smooth;
		return this;
	}
	
	@Override
	protected float calculateProgress(float time) { return smooth ? MathUtils.smoothLerp(startValue, endValue, time) : MathUtils.lerp(startValue, endValue, time); }
	@Override
	protected void onFinished() { finishProgress(); }
}
