#include "DeerStudio/StudioAPI/Environment.h"
#include "DeerStudio/AngelScriptEngine/AngelScriptRegisters.h"

namespace Deer {
	void registerEnvironmentStructs();
	void registerEnvironmentFunctions();

	void AngelScriptEngine::registerEnvironmentStructs() {
		AS_CHECK(scriptEngine->RegisterObjectType("Environment", sizeof(StudioAPI::EnvironmentStruct), asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<StudioAPI::EnvironmentStruct>() | asOBJ_APP_CLASS_ALLINTS));
	}

	void AngelScriptEngine::registerEnvironmentFunctions() {
		scriptEngine->SetDefaultNamespace("Resource");
		REGISTER_GLOBAL_FUNC("Environment getMainEnvironment()", StudioAPI::getMainEnvironment);
		REGISTER_GLOBAL_FUNC("Environment createLoadEnvironment(const string&in envId)", StudioAPI::createLoadEnvironment);
		scriptEngine->SetDefaultNamespace("");

		REGISTER_OBJECT_METHOD("Environment", "void render(FrameBuffer, SceneCamera&in)", StudioAPI::EnvironmentStruct, render);
		REGISTER_OBJECT_METHOD("Environment", "Entity getRootEntity()", StudioAPI::EnvironmentStruct, getRootEntity);
		REGISTER_OBJECT_METHOD("Environment", "Entity getEntity(int)", StudioAPI::EnvironmentStruct, getEntity);
	}
} // namespace Deer