class_name LaserCast extends RayCast3D
## Raycast for particle beams

const NORMAL_OFFSET = 0.05

@export var parent_tool: Spray

@onready var laser_dust: GPUParticles3D = %LaserDust
@onready var glow_light: OmniLight3D = %GlowLight


func _process(_delta: float) -> void:
	if is_colliding() and parent_tool.firing:
		var child_pos := get_collision_point() + get_collision_normal() * NORMAL_OFFSET
		for c: Node in get_children():
			if c is Node3D:
				(c as Node3D).global_position = child_pos

		laser_dust.emitting = true

		glow_light.visible = true  # TODO: tween maybe?
	else:
		laser_dust.emitting = false
		glow_light.visible = false
