extends Spatial


var targets = []

export var damage = 150
export var frequency = 0.1
export var enabled = true
export var time = 0.0


func _ready():
	$Timer.start(frequency)
	$MeshInstance.queue_free()
	if time > 0.0:
		$KillTimer.start(time)


func _on_Area_body_entered(body):
	targets.append(body)


func _on_Area_body_exited(body):
	targets.erase(body)


func _on_Timer_timeout():
	if targets.size() != 0 and enabled:
		for target in targets:
			if target.has_method("take_damage"):
				target.take_damage(damage)


func _on_KillTimer_timeout():
	queue_free()
