namespace BP
{
	namespace Weapon
	{
		class QuadMissileLauncher : ScriptWeapon
		{   
			//------------------------------------------------------------------------------------------------------------------------
			QuadMissileLauncher(kWeapon @actor)
			{
				id = kWpn_MissileLauncher;
				super(actor);
			}
			//------------------------------------------------------------------------------------------------------------------------
			void OnBeginFire(void) override
			{
				ScriptWeapon::OnBeginFire();
				self.Owner().ConsumeAmmo(1);
			}
			//------------------------------------------------------------------------------------------------------------------------
			void OnFiredParticleFromAnim(kParticle@ pMissile) override
			{
				ScriptWeapon::OnFiredParticleFromAnim(@pMissile);
				self.PlaySound("sounds/shaders/Scorpion Missile Launch.ksnd");
				
				// target is set if this weapon is able to track things
				if (self.GetTarget() is null)
				{
					return;
				}
				
				// have missile target the tracked object
				pMissile.SetTarget(self.GetTarget());
				
				// spawn a controller for manipulating the missile
				kActor@ pController =
				ActorFactory.Spawn(
					kActor_Misc_MissileController,
					pMissile.Origin(),
					0.0f,
					0.0f,
					0.0f);
					
				if (pController is null)
				{
					return;
				}
				
				// make controller target the missile so it can control it
				pController.SetTarget(pMissile);
			}
			//------------------------------------------------------------------------------------------------------------------------
		};
	}
}
