local MultiPolyTrailProjectile = import('/lua/sim/defaultprojectiles.lua').MultiPolyTrailProjectile 
local EffectTemplate = import('/lua/EffectTemplates.lua')

local Fire01Projectile = Class(MultiPolyTrailProjectile) {
    PolyTrails = {
		#'/effects/emitters/disintegrator_polytrail_01_emit.bp',#the white projectile thingie
		#'/effects/emitters/default_polytrail_03_emit.bp',#hardly visible line (good for normal projectiles)
		#'/effects/emitters/bomb_hit_fire_01_emit.bp',
		#'/mods/HawksmodFA/effects/emitters/fire_cloud_01_emit.bp',
	},
	#PolyTrailOffset = {0,0},    

    # Hit Effects
    #FxImpactUnit = EffectTemplate.CDisintegratorHitUnit01,
    #FxImpactProp = EffectTemplate.CDisintegratorHitUnit01,
    #FxImpactLand = EffectTemplate.CDisintegratorHitLand01,
    #FxImpactUnderWater = {},
	
	OnCreate = function(self, inWater)
		MultiPolyTrailProjectile.OnCreate(self, inWater)
		
		local projectile = self
		
		SetDamageThread = ForkThread(function(self)
			projectile.DamageData = {
	            DamageRadius = 0,
	            DamageAmount = 0,
	            DamageType = 'Normal',
	            DamageFriendly = false,
	            MetaImpactAmount = nil,
	            MetaImpactRadius = nil,
	        }
			KillThread(self)
		end)
				
		local army = self:GetArmy()
		local unit = self:GetLauncher()
		local muzzle = unit.lastFired
		local weapon = unit:GetWeapon(1)#TEMP UNTIL SET
		for i = 1, unit:GetWeaponCount() do
			if unit:GetBlueprint().Weapon[i].TurretBoneMuzzle == muzzle then
				weapon = unit:GetWeapon(i)
			end
		end
		
		SpawnFireEmittersThread = ForkThread(function(self)
			local fireAmount = 16
			for i = 1, fireAmount do
				#if (i == 4) or (i == 8) or (i == 12) then
				#	weapon:ChangeProjectileBlueprint('/mods/HawksmodFA/projectiles/ch_wpn_fire03/ch_wpn_fire03_proj.bp')
				#	weapon:CreateProjectile(muzzle)
				#end
				weapon:ChangeProjectileBlueprint('/mods/HawksmodFA/projectiles/ch_wpn_fire02/ch_wpn_fire02_proj.bp')
				weapon:CreateProjectile(muzzle)
				WaitSeconds(0.1)
			end
			weapon:ChangeProjectileBlueprint('/mods/HawksmodFA/projectiles/ch_wpn_fire01/ch_wpn_fire01_proj.bp')
			KillThread(self)
		end)
	end,
}

ch_wpn_fire01 = Class(Fire01Projectile) {}

TypeClass = ch_wpn_fire01