extends "res://scripts/Tower.gd"
## Tower Defense — Lecture 27 (Final)
##
## Projectile tower that spawns bullets to track and hit enemies.
## More expensive but longer range.

# ============================================================
# CONSTANTS
# ============================================================

var projectile_scene := preload("res://scenes/projectile.tscn")

func _ready() -> void:
	tower_cost = 150
	tower_damage = 10
	tower_range = 12.0
	attack_cooldown = 1.5
	
	super._ready()


# ============================================================
# ATTACK
# ============================================================

func _perform_attack() -> void:
	if not current_target:
		return
	
	# Spawn projectile
	var projectile := projectile_scene.instantiate()
	get_tree().root.add_child(projectile)
	
	projectile.global_position = global_position + Vector3.UP * 1.0
	projectile.target = current_target
	projectile.damage = tower_damage
