#include "DeerStudio/EditorEngine/API/Environment.h"
#include "DeerStudio/EditorEngine/ErrorHandle.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/API_Registration.h"

#include "angelscript.h"

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

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

        void registerEnvironmentFunctions() {
            scriptEngine->SetDefaultNamespace("Engine");
            REGISTER_GLOBAL_FUNC("Environment getMainEnvironment()", getMainEnvironment);
            REGISTER_GLOBAL_FUNC("Environment createEnvironment(const string&in)", createEnvironment);
            REGISTER_GLOBAL_FUNC("Environment getEnvironment(const string&in)", getEnvironment);
            scriptEngine->SetDefaultNamespace("");

            REGISTER_OBJECT_METHOD("Environment", "void render(FrameBuffer, SceneCamera&in)", EnvironmentStruct, render);
            REGISTER_OBJECT_METHOD("Environment", "Entity getRootEntity()", EnvironmentStruct, getRootEntity);
            REGISTER_OBJECT_METHOD("Environment", "Entity getEntity(int)", EnvironmentStruct, getEntity);
            REGISTER_OBJECT_METHOD("Environment", "string get_name() const property", EnvironmentStruct, getName);

        }
    }
}