#include <client/Main.h>

#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/packed_scene.hpp>
#include <godot_cpp/classes/resource_loader.hpp>
#include <godot_cpp/classes/scene_tree.hpp>
#include <godot_cpp/classes/window.hpp>
#include <godot_cpp/variant/utility_functions.hpp>

#include <client/ClientWorld.h>
#include <server/ServerWorld.h>

using namespace godot;

namespace blitz {

static constexpr char ClientWorldScenePath[] = "res://Scenes/Levels/client_world.tscn";
static constexpr char ServerWorldScenePath[] = "res://Scenes/Levels/server_world.tscn";

void Main::_bind_methods() {}

void Main::_ready() {
	auto* mainMenu = find_child("MainMenu");
	DEV_ASSERT(mainMenu);
	mainMenu->connect("change_scene_to_game", callable_mp(this, &Main::ChangeScene));
}

Main::Main() {}

Main::~Main() {}

void Main::ChangeScene(bool a_Server) {
	Ref<PackedScene> sceneData;
	if (a_Server)
		sceneData = ResourceLoader::get_singleton()->load(ServerWorldScenePath);
	else
		sceneData = ResourceLoader::get_singleton()->load(ClientWorldScenePath);

	add_child(sceneData->instantiate());
}

}  // namespace blitz