Files
fps_project_1/scripts/playlist_loader.gd
2025-03-01 16:11:20 -06:00

41 lines
1.3 KiB
GDScript

extends Node
@onready var playlist_generator: Control = $"../Playlist Generator"
var portals = []
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
if GameGlobals.current_match == [] or GameGlobals.current_match == null:
playlist_generator.load_playlist()
print("CURRENT MATCH : ",GameGlobals.current_match)
for i in get_tree().current_scene.get_children():
if i.is_in_group("portal"):
portals.append(i)
if GameGlobals.current_match[GameGlobals.current_round_id].size() == 0:
var next_round = GameGlobals.current_round_id + 1
if next_round <= (GameGlobals.current_match.size() - 1):
GameGlobals.current_round_id = next_round
var id = 0
for i in portals:
if id <= (GameGlobals.current_match[GameGlobals.current_round_id].size() - 1):
if GameGlobals.current_match[GameGlobals.current_round_id][id] != null:
var level_spawn = GameGlobals.current_match[GameGlobals.current_round_id][id]
i.index = id
i.active = true
i.scene_path = str(level_spawn["level_path"])
i.scene_name = str(level_spawn["level_name"])
i.level_gamemode = load(level_spawn["gamemode_path"])
else:
i.active = false
i.scene_name = "closed"
else:
i.active = false
i.scene_name = "closed"
id += 1
SaveLoad.save_user_data()