extends Node3D
class_name  Game

signal game_loaded

var init_config

func load_map():
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
	
	init_config = Runtimeloader.loadConfig("init.cfg") as ConfigFile
	
	print("Loading PCK...")
	for map_list in init_config.get_section_keys("MAPS"):
		for map in  init_config.get_value("MAPS", map_list):
			Runtimeloader.loadPCK(map)
			
	for weapons_list in init_config.get_section_keys("WEAPONS"):
		for weapon in init_config.get_value("WEAPONS", weapons_list):
			Runtimeloader.loadPCK(weapon)
	
	print("Loading Resources Done.")
	
	Runtimeloader.loadScene("maps/test_map.tscn", self)
	#Runtimeloader.get_all_entities(node)
	game_loaded.emit()

	
func _input(event):
	if event is InputEventKey and event.is_pressed():
		if event.keycode == KEY_F:
			if !DisplayServer.window_get_mode():
				DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
			else:
				DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
		elif event.keycode == KEY_ESCAPE:
			get_tree().quit()

