extends Position2D

var client = preload("res://scenes/Client.tscn")
var clientinst
var currentclient

export var client_type = 0
export var flipped = false
export var occupied = false

var rng = RandomNumberGenerator.new()

var time = 0

func randomizetype():
	client_type = rng.randi_range(0, 2)

func spawnclient():
	
	if get_node("Client") : get_node("Client").free()
	clientinst = client.instance()
	clientinst.name = "Client"
	
	match(client_type):
		0:
			clientinst.get_node("Body").animation = "SitH"
		1:
			clientinst.get_node("Body").animation = "SitN"
		2:
			clientinst.get_node("Body").animation = "SitM"
	clientinst.type = client_type
	
	if flipped: clientinst.scale[0] = -1
	add_child(clientinst)

func _ready():
	pass

func _process(delta):
	
	time += delta
	
	if time > 3:
		rng.randomize()
		if (rng.randi_range(0, 20) > 18) && !get_node("Client"):
			randomizetype()
			spawnclient()
		time = 0


