#include "app.h"
#include "render/renderapi.h"
#include "render/window.h"
#include "object/mesh/actor.h"
#include "data/property/actor_property.h"
#include "asset/file_manager.h"
#include "asset/resource_manager.h"
#include "object/scene/scene_manager.h"
namespace engineapi {
	App::App(const string& path)
	{
		const char* name = "zengine";
		SystemList.push_back(new FileManager());
		SystemList.push_back(new ResourceManager());
		SystemList.push_back(RenderAPI::MakeInstance());
		SystemList.push_back(Window::MakeInstance(3, 640, 720, name));
		SystemList.push_back(new SceneManager());
	}
	App::~App()
	{
		for (auto system : SystemList) {
			delete system;
		}
		SystemList.clear();
	}
	void App::Init()
	{
		for (auto system : SystemList) {
			system->Init();
		}
		for (auto system : SystemList) {
			system->LateInit();
		}
	}
	void App::Shutdown()
	{
		for (auto system : SystemList) {
			system->Shutdown();
		}
	}
	void App::Launch()
	{
		Init();
		while (Loop) {
			Update();
			Render();
		}
	}
	void App::Update()
	{
		SceneManager::GetSingletonPtr()->Update();
	}
	void App::Render()
	{
		RenderAPI::GetSingletonPtr()->BeginFrame();

		SceneManager::GetSingletonPtr()->Render();

		RenderAPI::GetSingletonPtr()->EndFrame();
	}
}
