Run lua scheduler with game time
This commit is contained in:
parent
dd0f60ed48
commit
8cd8b3f17e
@ -51,7 +51,7 @@ namespace scripting::lua
|
|||||||
|
|
||||||
for (auto i = tasks.begin(); i != tasks.end();)
|
for (auto i = tasks.begin(); i != tasks.end();)
|
||||||
{
|
{
|
||||||
const auto now = std::chrono::high_resolution_clock::now();
|
const auto now = *game::gameTime;
|
||||||
const auto diff = now - i->last_call;
|
const auto diff = now - i->last_call;
|
||||||
|
|
||||||
if (diff < i->delay)
|
if (diff < i->delay)
|
||||||
@ -105,8 +105,8 @@ namespace scripting::lua
|
|||||||
task task;
|
task task;
|
||||||
task.is_volatile = is_volatile;
|
task.is_volatile = is_volatile;
|
||||||
task.callback = callback;
|
task.callback = callback;
|
||||||
task.delay = delay;
|
task.delay = static_cast<int>(delay.count());
|
||||||
task.last_call = std::chrono::steady_clock::now();
|
task.last_call = *game::gameTime;
|
||||||
task.id = id;
|
task.id = id;
|
||||||
task.is_deleted = false;
|
task.is_deleted = false;
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ namespace scripting::lua
|
|||||||
class task final : public task_handle
|
class task final : public task_handle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::chrono::steady_clock::time_point last_call{};
|
int last_call{};
|
||||||
sol::protected_function callback{};
|
sol::protected_function callback{};
|
||||||
std::chrono::milliseconds delay{};
|
int delay{};
|
||||||
bool is_volatile = false;
|
bool is_volatile = false;
|
||||||
bool is_deleted = false;
|
bool is_deleted = false;
|
||||||
std::vector<std::pair<entity, std::string>> endon_conditions{};
|
std::vector<std::pair<entity, std::string>> endon_conditions{};
|
||||||
|
@ -196,6 +196,8 @@ namespace game
|
|||||||
WEAK symbol<scrVmPub_t> scr_VmPub{0x14BA9EE40};
|
WEAK symbol<scrVmPub_t> scr_VmPub{0x14BA9EE40};
|
||||||
WEAK symbol<function_stack_t> scr_function_stack{0x14BAA93C0};
|
WEAK symbol<function_stack_t> scr_function_stack{0x14BAA93C0};
|
||||||
|
|
||||||
|
WEAK symbol<int> gameTime{0x1455CC780};
|
||||||
|
|
||||||
WEAK symbol<DB_FileSysInterface*> g_fileSystem{0x1420B27E8};
|
WEAK symbol<DB_FileSysInterface*> g_fileSystem{0x1420B27E8};
|
||||||
|
|
||||||
WEAK symbol<map_t> maps{0x14097EE90};
|
WEAK symbol<map_t> maps{0x14097EE90};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user