extends MultiplayerSpawner

@onready var player_scene: PackedScene = load("res://player/Player.tscn")


func _ready() -> void:
	spawn_function = spawn_player


func spawn_player(data: Dictionary) -> Player:
	var new_player = player_scene.instantiate() as Player
	
	var peer_id = str(data["peer_id"])
	var player_name = str(data["player_name"])
	
	new_player.set_multiplayer_authority(int(peer_id), true)
	new_player.set_player_name(peer_id, player_name)
	new_player.position = Vector3.UP
	
	GameManager.players.append(int(peer_id))
	
	return new_player
