enum ELaunchMode
{
	Primary = 0,
	Secondary = 1,
	None = 2,
}

class NanoWireProjectile extends BaseProjectile
{
	var m_maxAttackRange : Float;
	default m_maxAttackRange = 0.f;
	protected var m_launchMode : ELaunchMode;

	protected final function SetNanoWireProjectileLaunchMode()
	{
		var isPrimary : Bool;
		isPrimary = true;
		if( isPrimary )
		{
			m_launchMode = ELaunchMode.Primary;
		}
		else if( !( isPrimary ) )
		{
			m_launchMode = ELaunchMode.Secondary;
		}
		else
		{
			m_launchMode = ELaunchMode.None;
		}
	}

	protected event OnProjectileInitialize( eventData : gameprojectileSetUpEvent )
	{
		super.OnProjectileInitialize( eventData );
		SetNanoWireProjectileLaunchMode();
		m_projectileComponent.SetCollisionEvaluator( new NanoWireProjectileCollisionEvaluator );
		m_maxAttackRange = GameInstance.GetStatsSystem( m_user.GetGame() ).GetStatValue( ( ( EntityID )( m_user.GetEntityID() ) ), gamedataStatType.Range );
		m_maxAttackRange *= 2.0;
	}

	protected event OnShoot( eventData : gameprojectileShootEvent )
	{
		GeneralLaunchSetup( eventData );
		LinearLaunch( eventData, GetProjectileTweakDBFloatParameter( "startVelocity" ) );
	}

	protected event OnShootTarget( eventData : gameprojectileShootTargetEvent )
	{
		var targetComponent : IPlacedComponent;
		GeneralLaunchSetup( eventData );
		targetComponent = eventData.params.trackedTargetComponent;
		if( targetComponent )
		{
			m_initialLaunchVelocity = GetProjectileTweakDBFloatParameter( "startVelocity" );
			CurvedLaunchToTarget( eventData, , targetComponent );
		}
		else
		{
			LinearLaunch( eventData, GetProjectileTweakDBFloatParameter( "startVelocity" ) );
		}
	}

	protected event OnCollision( eventData : gameprojectileHitEvent )
	{
		var attackRecord : Attack_Record;
		var attackRadius : Float;
		var puppet : NPCPuppet;
		var hitInstance : gameprojectileHitInstance;
		super.OnCollision( eventData );
		hitInstance = eventData.hitInstances[ 0 ];
		puppet = ( ( NPCPuppet )( hitInstance.hitObject ) );
		if( !( puppet ) || !( ScriptedPuppet.IsActive( puppet ) ) )
		{
			return false;
		}
		if( m_launchMode == ELaunchMode.Primary )
		{
			attackRecord = TweakDBInterface.GetAttackRecord( T"Attacks.NanoWireNonLethalGrapple" );
		}
		else if( m_launchMode == ELaunchMode.Secondary )
		{
			attackRecord = TweakDBInterface.GetAttackRecord( T"Attacks.NanoWireLethalGrapple" );
		}
		else
		{
			attackRecord = TweakDBInterface.GetAttackRecord( T"Attacks.NanoWireNonLethalGrapple" );
		}
		attackRadius = attackRecord.Range();
		ProjectileHitAoE( hitInstance, attackRadius, attackRecord );
	}

}

class NanoWireProjectileCollisionEvaluator extends gameprojectileScriptCollisionEvaluator
{

	protected override function EvaluateCollision( defaultOnCollisionAction : gameprojectileOnCollisionAction, params : CollisionEvaluatorParams ) : gameprojectileOnCollisionAction
	{
		if( params.target.IsNPC() )
		{
			return gameprojectileOnCollisionAction.StopAndStick;
		}
		return gameprojectileOnCollisionAction.Bounce;
	}

}

