class_name Railgun extends "res://scenes/weapon/weapon.gd"

@onready var bullet = preload("res://scenes/bullet/bulletRailgun/bulletRailgun.tscn")

func attack():
	if cooldownTimer.is_stopped():
		shoot.play()
		spawnBullet()
		cooldownTimer.start(cooldown)

func spawnBullet():
	var newBullet: Bullet = bullet.instantiate()
	newBullet.spawn(bulletPoint.global_position, get_parent().get_parent().rotation, damage, penetration, bulletSpeed)
	newBullet.fromTimeGhost = get_parent().get_parent().is_in_group("timeGhost")
	get_tree().get_first_node_in_group("bulletPool").add_child(newBullet)
