class_name PlayerManager extends Node3D var id_to_player = {} func _ready(): Global.players = self var timer := %UpdatePlayers as Timer timer.timeout.connect(tick) func tick(): var visible_players := PerformanceComponent.get_visible_players_sorted_by_distance() AnimationPerformance.update_animation_quality(visible_players) func add(player: Player): if has(player.id): return add_child(player) id_to_player[player.id] = player func get_player(id: String) -> Player: return id_to_player.get(id) as Player func has(id: String) -> bool: return id_to_player.has(id) func remove(id: String): if !id_to_player.has(id): return id_to_player[id].queue_free() id_to_player.erase(id)