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