Tesseract-Engine/src/Componenets/ScriptComponent.h

46 lines
1.2 KiB
C
Raw Normal View History

2024-12-27 21:27:05 +00:00
// ScriptComponent.hpp
#pragma once
#include "Component.h"
#include <string>
#include <yaml-cpp/yaml.h>
#include "Windows/LoggerWindow.h"
#include "Engine/LuaAPI.h" // Include the LuaManager class
#include <unordered_map>
2024-12-27 21:27:05 +00:00
class ScriptComponent : public Component
{
public:
ScriptComponent();
virtual ~ScriptComponent();
std::string ScriptPath; // Path to the Lua script
2024-12-27 21:27:05 +00:00
// Component interface implementation
virtual const std::string &GetName() const override;
static const std::string &GetStaticName();
2024-12-27 21:27:05 +00:00
virtual YAML::Node Serialize() override;
virtual void Deserialize(const YAML::Node &node) override;
2024-12-27 21:27:05 +00:00
// Script management methods
bool Initialize();
virtual void Update(float deltaTime);
void Init();
void UpdateVariable(const std::string &name, const LuaManager::LuaExposedVariant &value);
std::unordered_map<std::string, LuaManager::LuaExposedVariant> GetExposedVariables();
2024-12-27 21:27:05 +00:00
private:
LuaManager m_LuaManager; // Instance of LuaManager
std::string m_LastErrorMessage; // To prevent duplicate error logs
2024-12-27 21:27:05 +00:00
2024-12-28 19:06:42 +00:00
// block copying
ScriptComponent(const ScriptComponent &) = delete;
ScriptComponent &operator=(const ScriptComponent &) = delete;
2024-12-27 21:27:05 +00:00
static const std::string name;
};