extends EffectBase
class_name Particle

var particle_list : Array[GPUParticles3D]
var speed_scale_list = []
var decal_list = []

func on_ready():
	for child in get_children():
		if child is GPUParticles3D:
			var particle = child as GPUParticles3D
			particle_list.append(particle)
			speed_scale_list.append(particle.speed_scale)
			particle.restart()
		elif child is ParticleDecal:
			decal_list.append(child)
		else:
			continue
		if child.lifetime > life_time_now:
			life_time_now = child.lifetime
			
	for particle : GPUParticles3D in particle_list:
		if particle.lifetime > life_time_now:
			life_time_now = particle.lifetime

func on_process(delta:float):
	for decal : ParticleDecal in decal_list:
		decal.on_process(delta)

func on_set_pause(is_pause_set:bool):
	for i in range(len(particle_list)):
		var particle = particle_list[i]
		var speed_scale = speed_scale_list[i]
		particle.speed_scale = 0 if is_pause else speed_scale
