iw5-mod/src/module/scripting.hpp

45 lines
1.0 KiB
C++
Raw Normal View History

2019-01-13 13:03:46 -05:00
#pragma once
#include "loader/module_loader.hpp"
#include "game/game.hpp"
#include "utils/hook.hpp"
class scripting final : public module
{
public:
class variable final
{
public:
variable(game::native::VariableValue value);
~variable();
operator game::native::VariableValue() const;
private:
game::native::VariableValue value_;
};
2019-01-13 15:28:05 -05:00
void post_start() override;
2019-01-13 13:03:46 -05:00
void post_load() override;
void pre_destroy() override;
static void on_start(const std::function<void()>& callback);
static void on_stop(const std::function<void()>& callback);
private:
std::unique_ptr<chaiscript::ChaiScript> chai_;
2019-01-13 15:28:05 -05:00
std::vector<std::function<void(const std::string&, const std::vector<chaiscript::Boxed_Value>&)>> callbacks_;
void initialize();
void load_scripts() const;
2019-01-13 13:03:46 -05:00
static utils::hook start_hook_;
static utils::hook stop_hook_;
static std::mutex mutex_;
static std::vector<std::function<void()>> start_callbacks_;
static std::vector<std::function<void()>> stop_callbacks_;
static void start_execution();
static void stop_execution();
};