#pragma once
#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptInfo.h"
#include "DeerStudio/EditorEngine/ServiceScript/ServiceScriptObject.h"
#include <vector>

class asIScriptModule;
class asIScriptContext;

namespace Deer {
    namespace EditorEngine {
        class ServiceScriptContext {
        public:
            ServiceScriptContext(asIScriptModule*, ServiceScriptInfo*);
            ~ServiceScriptContext();

            ServiceScriptContext(ServiceScriptContext&) = delete;
            ServiceScriptContext& operator=(ServiceScriptContext&) = delete;

            ServiceScriptContext(ServiceScriptContext&&);
            ServiceScriptContext& operator=(ServiceScriptContext&&);
            
            void update();
            void init();

            void bindFunctions();

            inline const char* getName() const { return info->name.c_str(); }
            inline const ServiceScriptInfo& getInfo() const { return *info; }

            std::vector<ServiceScriptObject> scriptServices;
        private:
            asIScriptContext* context;
            asIScriptModule* module;
            ServiceScriptInfo* info;
        };
    }
}