extends Node2D

var current_target
var can_shoot = true

func _ready():
	pass

var zeroPoint = Vector2(-60, -1015)

func _process(delta):
	pass


func entityEnteredRange(bad_id, bad, bad_shape, self_shape):
	print(bad.get_name())
	if ("Bad" in bad.get_name()) && can_shoot:
		current_target = bad_id
		#var local_pos = zeroPoint + area.position
		var local_pos = Vector2()
		local_pos = to_local(bad.position)
		$Beam.set_point_position(1, local_pos)
		$TurretSprite.rotation = ($Beam.get_point_position(0).angle_to($Beam.get_point_position(1))) + PI/5.3
		print($Beam.get_point_position(0).angle_to($Beam.get_point_position(1)))
		$Beam.default_color.a = 200
		$TurretSprite.frame = 1
		bad.hit("turret")
		$FlashTimer.start()
		can_shoot = false

func _on_FlashTimer_timeout():
	$Beam.default_color.a = 0
	$TurretSprite.frame = 0
	pass # replace with function body

func _on_ReloadTimer_timeout():
	can_shoot = true
	pass # replace with function body
