22 lines
346 B
GDScript
22 lines
346 B
GDScript
class_name PlayerManager
|
|
extends Node3D
|
|
|
|
var players = {}
|
|
|
|
func _ready():
|
|
Global.players = self
|
|
|
|
func add(player: Player):
|
|
add_child(player)
|
|
players[player.id] = player
|
|
|
|
func get_player(id: String) -> Player:
|
|
return players[id] as Player
|
|
|
|
func remove(id: String):
|
|
if !players.has(id):
|
|
return
|
|
|
|
players[id].queue_free()
|
|
players.erase(id)
|