class_name Spray extends Tool
## Base class for spraygun tools

const RUMBLE_INTENSITY = 0.002
const RUMBLE_DROPOFF = 0.8

@onready var spray_effect: MeshInstance3D = %SprayEffect
@onready var beam_particles_1: GPUParticles3D = %BeamParticles1
@onready var beam_particles_2: GPUParticles3D = %BeamParticles2
@onready var rumbler: Rumbler3D = %Rumbler
@onready var beam_sfx: BeamSFX = %BeamSFX


func _spray() -> void:
	pass  ## Implemented in derived type


func _fire() -> void:
	rumbler.intensity = RUMBLE_INTENSITY

	if Game.manager.is_tank_full():
		Player.instance.hud.play_tank_full_alert()
		idle()
		return

	_spray()

	spray_effect.visible = true
	beam_particles_1.emitting = true
	beam_particles_2.emitting = true

	beam_sfx.activate()


func _idle() -> void:
	spray_effect.visible = false
	beam_particles_1.emitting = false
	beam_particles_2.emitting = false
	rumbler.intensity *= RUMBLE_DROPOFF
