module vs.bullet.fist;



public import vs.action.bullet;
private import gedo.audio.sound;
private import gedo.video.skinnedmesh;
private import vs.action.effect;
private import vs.action.visualtask;



public class Fist : Bullet
{
public:
	this(Power p, Sound se, EffectProgram effect, Timer timer, uint term = 1)
	{
		_effect = effect;
		_power  = p;
		_se     = se;

		_timer  = timer;

		_term.time = term;
	}


	override void onUpdate()
	{
		if(_term.index == _timer.index && _time < _term.time)
		{
			return;
		}

		stop();
	}


	override void onStart()
	{
		_term.index = _timer.index;

		_localPosition[] = position.current[];
	}


	override void updateRelativePosition()
	{
		auto c = cast(VisualTask)parent;

		direction.copyFrom(c.direction);

		direction.toVector(_localPosition[0], _localPosition[1], _localPosition[2], position.current);

		.gedo.math.vector.add(position.current, c.position.current);

		position.previous[] = position.current[];
	}


	override BulletType type()
	{
		return BulletType.HIT;
	}


	override Power power()
	{
		return _power;
	}


	override Sound hitSE()
	{
		return _se;
	}


	override EffectProgram hitEffect()
	{
		return _effect;
	}


private:
	struct Term
	{
		uint index;
		uint time;
	}


	EffectProgram _effect;
	Vector        _localPosition;
	Power         _power;
	Sound         _se;
	Timer         _timer;
	Term          _term;
}
