#include "DeerStudio/EditorEngine/API/Environment.h"
#include "Deer/Enviroment.h"
#include "DeerRender/FrameBuffer.h"
#include "DeerRender/SceneCamera.h"
#include "Deer/Scene.h"

namespace Deer {
    namespace EditorEngine {
        void EnvironmentStruct::render(FrameBufferHandleStruct frameBuffer_handle, SceneCamera& sc) {
            FrameBuffer& frameBuffer = FrameBufferManager::getFrameBuffer(frameBuffer_handle.frameBufferId);
            Environment& env = EnvironmentManager::getEnvironment(environmentId);

            frameBuffer.bind();
            
            // TODO
            Scene::render(sc);
            //env.render(sceneCamera);

            frameBuffer.unbind();
        }

        EntityHandleStruct EnvironmentStruct::getRootEntity() {
            return EntityHandleStruct(0, environmentId);
        }

        EntityHandleStruct EnvironmentStruct::getEntity(int id) {
            return EntityHandleStruct(id, environmentId);
        }

        std::string EnvironmentStruct::getName() {
            return EnvironmentManager::getEnvironmentName(environmentId);
        }

        EnvironmentHandleStruct getMainEnvironment() {
            return EnvironmentHandleStruct(0);
        }

        EnvironmentHandleStruct createEnvironment(std::string& name) {
            return EnvironmentHandleStruct(EnvironmentManager::createEnvironment(name));
        }

        EnvironmentHandleStruct getEnvironment(std::string& name) {
            return EnvironmentHandleStruct(EnvironmentManager::getEnvironmentId(name));
        }
    }
}