TmpMenu/src/script_mgr.cpp
maybegreat48 97a8c5d60b Add more spoofing options and added clang-format (#1020)
* feat(Spoofing): add spoofing
* feat(Spoofing): prepare code for player attach
* remove(PlayerAttach): isn't going to work due to netsync architecture
* fix(GUI): fix scaling
* feat(Project): add clang-format file
* feat(Classes): update classes
* fix(BlackHole): remove unnecessary cleanup
* fix(Formatting): fix formatting for initializer lists
* feat(clang-format): Set tab width and 1 space before comment

Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
2023-03-01 21:27:15 +00:00

44 lines
885 B
C++

#include "script_mgr.hpp"
#include "common.hpp"
#include "gta/script_thread.hpp"
#include "gta/tls_context.hpp"
#include "gta_util.hpp"
#include "invoker.hpp"
#include "pointers.hpp"
namespace big
{
void script_mgr::add_script(std::unique_ptr<script> script)
{
std::lock_guard lock(m_mutex);
m_scripts.push_back(std::move(script));
}
void script_mgr::remove_all_scripts()
{
std::lock_guard lock(m_mutex);
m_scripts.clear();
}
script_list& script_mgr::scripts()
{
return m_scripts;
}
void script_mgr::tick()
{
gta_util::execute_as_script(RAGE_JOAAT("main_persistent"), std::mem_fn(&script_mgr::tick_internal), this);
}
void script_mgr::tick_internal()
{
static bool ensure_main_fiber = (ConvertThreadToFiber(nullptr), true);
std::lock_guard lock(m_mutex);
for (auto const& script : m_scripts)
if (script->is_enabled())
script->tick();
}
}