module vs.action.effect;



private import gedo.video.alphameshlist;
private import vs.action.visualtask;



alias AlphaMeshList delegate() GetAlphaMeshList;



public class EffectTask : VisualTask
{
public:
	this(GetAlphaMeshList dg)
	{
		_list = dg;
	}


	void start(EffectProgram p)
	{
		_time    = -1;
		_program = p;
	}


	override void update()
	{
		super.update();

		++_time;

		if(_program.isLiving(this))
		{
			_program.update(this);
		}
		else
		{
			stop();
		}
	}


	override void draw()
	{
		_program.draw(this);
	}


	int time()
	{
		return _time;
	}


	void drawAlpha()
	{
		_program.drawAlpha(this);
	}


	AlphaMeshList list()
	{
		return _list();
	}


private:
	GetAlphaMeshList _list;
	EffectProgram    _program;
	int              _time;
}



public interface EffectProgram
{
	void update(EffectTask t);
	void draw(EffectTask t);
	void drawAlpha(EffectTask t);
	bool isLiving(EffectTask t);
}
