extends Area

onready var turret_main = get_node("../../../../")

var allowed_groups = ["missile", "railgun_target"];
var seen_nodes = []

func _body_entered(body: Node):
	var proceed = false;
	for allowed_group in allowed_groups:
		if body.is_in_group(allowed_group):
			proceed = true;
			break;
	if not proceed:
		return;
	
	print(body.get_parent().name+" just entered the vision!");
	seen_nodes.append(body);

func _body_exited(body: Node):
	var proceed = false;
	for allowed_group in allowed_groups:
		if body.is_in_group(allowed_group):
			proceed = true;
			break;
	if not proceed:
		return;
	
	print(body.get_parent().name+" just left the vision!");
	seen_nodes.remove(self.seen_nodes.find(body));

func _ready():
	print("TurretVision online!");
	connect('body_entered', self, '_body_entered');
	connect('body_exited', self, '_body_exited');
