2024-01-28 18:18:16 +00:00
|
|
|
class_name PlayerManager
|
|
|
|
extends Node3D
|
|
|
|
|
|
|
|
var players = {}
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
Global.players = self
|
|
|
|
|
|
|
|
func add(player: Player):
|
2024-01-29 22:16:06 +00:00
|
|
|
if has(player.id):
|
|
|
|
return
|
|
|
|
|
2024-01-28 18:18:16 +00:00
|
|
|
add_child(player)
|
|
|
|
players[player.id] = player
|
|
|
|
|
|
|
|
func get_player(id: String) -> Player:
|
|
|
|
return players[id] as Player
|
|
|
|
|
2024-01-29 22:16:06 +00:00
|
|
|
func has(id: String) -> bool:
|
|
|
|
return players.has(id)
|
|
|
|
|
2024-01-28 18:18:16 +00:00
|
|
|
func remove(id: String):
|
2024-01-28 21:08:08 +00:00
|
|
|
if !players.has(id):
|
|
|
|
return
|
|
|
|
|
2024-01-28 18:18:16 +00:00
|
|
|
players[id].queue_free()
|
|
|
|
players.erase(id)
|