namespace BP
{
	namespace Weapon
	{
		class CerebralBore : ScriptWeapon
		{
			//------------------------------------------------------------------------------------------------------------------------
			CerebralBore(kWeapon @actor)
			{
				id = kWpn_Bore;
				super(actor);
			}
			//------------------------------------------------------------------------------------------------------------------------
			void OnFiredParticleFromAnim(kParticle@ pMissile) override
			{
				ScriptWeapon::OnFiredParticleFromAnim(@pMissile);
				// 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_BoreController,
					pMissile.Origin(),
					0.0f,
					0.0f,
					0.0f);
					
				if (pController is null)
				{
					return;
				}
				
				// pController.PlayLoopingSound("sounds/shaders/Cerebral Bore Track Loop.ksnd");
				
				// make controller target the missile so it can control it
				pController.SetTarget(pMissile);
				
				// push the controller over the network for client replication
				if (Network.IsNetgame() && Network.IsServer() && !(pMissile.GetTarget() is null))
				{
					NetSend::Clear();
					
					// writes NPN_SCRIPT and then the string of the global function decl
					NetSend::WriteScriptHeader("void NetworkRecvSpawnBoreController(void)");
					NetSend::WriteInt16(pMissile.NetID());
					NetSend::WriteInt16(pMissile.GetTarget().NetID());
					
					// transmit pbuffer
					// when client recieves this, it parses the string which is the decl to the global function and then calls it
					Network.TransmitToAll();
				}
			}
			//------------------------------------------------------------------------------------------------------------------------
		};
	}
}
