extends Node3D

var player_side: String

@onready var intro_camera = $Intro/CameraMount/IntroCamera
@onready var intro_view_port = $Intro/CameraMount/IntroCamera/SubViewportContainer/SubViewport
@onready var spawns = $Spawns
@onready var root = $'.' 
@onready var players = $Players

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	var char : Node3D = null
	var red_spawn: Node3D = $Spawns/Blue/SpawnArea
	var position := red_spawn.global_position
	if multiplayer.is_server():
		for i in GameServerManager.players:
			char = ResourceLoader.load("res://scenes/characters/placeholder.tscn").instantiate()
			char.name = "PlayerPlaceholder_" + str(GameServerManager.players[i].name)
			char.global_position = position
			var my_random_number = RandomNumberGenerator.new().randf_range(0.0, 5.0)
			char.global_position = position
			char.global_position.x += my_random_number
			char.global_position.y += 300 + my_random_number
			char.global_position.z += my_random_number
			$MultiplayerSpawner.spawn(char)
			players.add_child(char)

var bullet_amount: int = 0
func spawn_bullet(position):
	print("spawning a bullet")
	var node: Node3D = ResourceLoader.load("res://scenes/weapon/bullet.tscn").instantiate()
	node.position = position.global_position
	node.transform.basis = position.global_transform.basis
	node.name = str(bullet_amount)
	bullet_amount += 1
	#$BulletSpawner.spawn(node)
	$Bullets.add_child(node)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass
