extends Node2D


onready var status = get_node("ParallaxBackground/Status")


func _ready():
	Servilo.connect("connection_failed", self, "_on_connection_failed")
	Servilo.connect("connection_succeeded", self, "_on_connection_success")
	Servilo.connect("server_disconnected", self, "_on_server_disconnect")
	Servilo.connect("players_updated", self, "update_players_list")
	Servilo.my_name = Global.login
	Servilo.connect_to_server()


func _on_connection_success():
	status.text = "Connected"
	status.modulate = Color.green


func _on_connection_failed():
	status.text = "Connection Failed, trying again"
	status.modulate = Color.red


func _on_server_disconnect():
	status.text = "Server Disconnected, trying to connect..."
	status.modulate = Color.red
	

func update_players_list():
	pass
#	$Panel/Players.text = String(gamestate.get_player_list())
