namespace BP
{
	namespace Controller
	{
		class CerebralBore : ScriptObject
		{
			kActor@ self;
			//------------------------------------------------------------------------------------------------------------------------
			CerebralBore(kActor@ actor)
			{
				@self = actor;
			}
			//------------------------------------------------------------------------------------------------------------------------
			void OnTick(void)
			{
				if (self.GetTarget() is null)
				{
					self.Remove();
					return;
				}
				
				kParticle@ pParticle = self.GetTarget().CastToParticle();
				if (pParticle is null)
				{
					self.Remove();
					return;
				}
				
				if (pParticle.IsStale() || (pParticle.GetTarget() is null))
				{
					self.Remove();
					return;
				}
				
				if (pParticle.GetTarget().Health() <= 0)
				{
					self.Remove();
					return;
				}
				
				self.Origin() = pParticle.Origin();
				self.PlayLoopingSound("sounds/shaders/Cerebral Bore Track Loop.ksnd");
				
				if (pParticle.IsSticking())
				{
					pParticle.GetTarget().PlaySound("sounds/shaders/Cerebral Bore Boring.ksnd");
					self.Remove();
					return;
				}
			}
			//------------------------------------------------------------------------------------------------------------------------
		};
	}
}
