extends Node3D
@onready var rocket = $"1_StartRocket"
@onready var explosion = $"2_MainExplosion"
@onready var trails = $"3_FallingTrails"

func set_color(target_color: Color) -> void:
	#set colors
	set_particles_node_color(rocket, Color(1.5, 1.5, 1.5))
	set_particles_node_color(explosion, Color(1.2, 1.2, 1.2))
	set_particles_node_color(trails, target_color)

func set_particles_node_color(node: GPUParticles3D, new_color: Color) -> void:
	if node and node.draw_pass_1:
		var mesh = node.draw_pass_1 as QuadMesh
		if mesh and mesh.material:
			var unique_mat = mesh.material.duplicate() as StandardMaterial3D
			unique_mat.albedo_color = new_color
			unique_mat.blend_mode = BaseMaterial3D.BLEND_MODE_ADD #Light effect (glow)
			unique_mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
			mesh.material = unique_mat

func turnon() -> void:
	if rocket:
		rocket.emitting = true
		
	await get_tree().create_timer(6.0).timeout
	queue_free()
