class SpiderbotHeavyProjectile extends BaseProjectile
{
	private var m_meshComponent : IComponent;
	private editable var m_effect : EffectRef;
	private editable var m_startVelocity : Float;
	private editable var m_lifetime : Float;
	private var m_alive : Bool;
	default m_alive = true;
	private var m_hit : Bool;
	default m_hit = false;

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		super.OnTakeControl( ri );
		m_meshComponent = EntityResolveComponentsInterface.GetComponent( ri, 'MeshComponent' );
	}

	private function Reset()
	{
		m_alive = true;
		m_hit = false;
		m_meshComponent.Toggle( true );
	}

	protected event OnShoot( eventData : gameprojectileShootEvent )
	{
		SetInitialVelocityBasedOnActionType( m_user );
		ParabolicLaunch( eventData, -10.0, 15.0, 0.0 );
	}

	protected event OnShootTarget( eventData : gameprojectileShootTargetEvent )
	{
		var parabolicParams : ParabolicTrajectoryParams;
		Reset();
		parabolicParams = ParabolicTrajectoryParams.GetAccelTargetAngleParabolicParams( Vector4( 0.0, 0.0, -10.0, 0.0 ), eventData.params.targetPosition, 30.0 );
		m_projectileComponent.SetEnergyLossFactor( 0.1, 0.1 );
		m_projectileComponent.AddParabolic( parabolicParams );
		m_projectileComponent.SetOnCollisionAction( gameprojectileOnCollisionAction.Stop );
	}

	protected event OnCollision( eventData : gameprojectileHitEvent )
	{
		if( m_alive )
		{
			GameObject.PlaySoundEvent( this, 'Stop_Time_Dilation_Bullet_Trails_bullets_normal' );
			Explode( eventData.hitInstances[ 0 ] );
		}
	}

	protected virtual function Explode( const hitInstance : ref< gameprojectileHitInstance > )
	{
		var effect : EffectInstance;
		var damageHitEvent : gameprojectileHitEvent;
		damageHitEvent = new gameprojectileHitEvent;
		damageHitEvent.hitInstances.PushBack( hitInstance );
		effect = m_projectileComponent.GetGameEffectInstance();
		EffectData.SetVariant( effect.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.projectileHitEvent, damageHitEvent );
		EffectData.SetVector( effect.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.position, hitInstance.position );
		EffectData.SetFloat( effect.GetSharedData(), GetAllBlackboardDefs().EffectSharedData.radius, 5.0 );
		effect.Run();
		m_alive = false;
		m_meshComponent.Toggle( false );
		m_projectileComponent.ClearTrajectories();
	}

}

