class nanowireGrenade extends BaseProjectile
{
	private var m_countTime : Float;
	private editable var m_timeToActivation : Float;
	private editable var m_energyLossFactor : Float;
	private editable var m_startVelocity : Float;
	private editable var m_grenadeLifetime : Float;
	private editable var m_gravitySimulation : Float;
	private var m_trailEffectName : CName;
	default m_trailEffectName = 'trail';
	private var m_alive : Bool;
	default m_alive = true;

	protected event OnProjectileInitialize( eventData : gameprojectileSetUpEvent )
	{
		m_projectileComponent.SetEnergyLossFactor( m_energyLossFactor, 0.05 );
	}

	private function StartTrailEffect()
	{
		var spawnEffectEvent : entSpawnEffectEvent;
		spawnEffectEvent = new entSpawnEffectEvent;
		spawnEffectEvent.effectName = m_trailEffectName;
		QueueEvent( ( ( Event )( spawnEffectEvent ) ) );
	}

	private function Reset()
	{
		m_countTime = 0.0;
		m_alive = true;
	}

	protected event OnShoot( eventData : gameprojectileShootEvent ) {}

	protected event OnShootTarget( eventData : gameprojectileShootTargetEvent )
	{
		if( m_alive )
		{
			Explode( eventData.startPoint );
			Release();
			m_alive = false;
		}
	}

	protected event OnTick( eventData : gameprojectileTickEvent ) {}

	protected event OnCollision( eventData : gameprojectileHitEvent )
	{
		var evt : gameprojectileShootTargetEvent;
		evt = new gameprojectileShootTargetEvent;
		evt.startPoint = eventData.hitInstances[ 0 ].position;
		GameInstance.GetDelaySystem( GetGame() ).DelayEvent( this, evt, m_timeToActivation );
		StopMovement();
	}

	private function Explode( position : Vector4 )
	{
		var explosionEffect : EffectInstance;
		explosionEffect = m_projectileComponent.GetGameEffectInstance();
		EffectData.SetVector( explosionEffect.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.position, position );
		explosionEffect.Run();
	}

	private function StopMovement()
	{
		m_projectileComponent.ClearTrajectories();
	}

}

class EffectExecutor_NanowireGrenadePull extends EffectExecutor_Scripted
{

	public function Process( ctx : EffectScriptContext, applierCtx : EffectExecutionScriptContext ) : Bool
	{
		PullTarget( ( ( GameObject )( EffectExecutionScriptContext.GetTarget( applierCtx ) ) ), ( ( GameEntity )( EffectScriptContext.GetSource( ctx ) ) ).GetWorldPosition() );
		return true;
	}

	protected function PullTarget( target : GameObject, impactPosition : Vector4 )
	{
		var stimuliEffectEvent : StimuliEffectEvent;
		if( target )
		{
			stimuliEffectEvent = new StimuliEffectEvent;
			stimuliEffectEvent.stimuliEventName = 'GetOverHere';
			stimuliEffectEvent.targetPoint = impactPosition;
			target.QueueEvent( stimuliEffectEvent );
		}
	}

}

