8#include <entt/locator/locator.hpp>
9#include <SDL3/SDL_timer.h>
22 auto& lua = entt::locator<sol::state>::value();
26 lua.set_function(
"time_set_dt", sol::resolve<
void(
const double)>(&
time::dt));
27 lua.set_function(
"time_get_dt", sol::resolve<
double(
void)>(&
time::dt));
36 lua.set(
"GALAXY_MS_PER_SECOND", SDL_MS_PER_SECOND);
37 lua.set(
"GALAXY_NS_PER_MS", SDL_NS_PER_MS);
38 lua.set(
"GALAXY_NS_PER_SECOND", SDL_NS_PER_SECOND);
39 lua.set(
"GALAXY_NS_PER_US", SDL_NS_PER_US);
40 lua.set(
"GALAXY_US_PER_SECOND", SDL_US_PER_SECOND);
42 auto stopwatch_type = lua.new_usertype<
Stopwatch>(
"Stopwatch", sol::constructors<Stopwatch()>());
54 auto timer_type = lua.new_usertype<
Timer>(
"Timer", sol::constructors<Timer()>());
static void inject_time() noexcept
Register galaxy time support functions into Lua.
void stop()
Stop Stopwatch.
void pause()
Pause the Stopwatch.
void unpause()
Resume the Stopwatch.
void start()
Start Stopwatch.
void repeat(const bool repeat)
Make function repeat itself instead of running once.
bool paused() const
Is the Stopwatch paused?
void update()
Call this if you want to trigger the callback after delay has passed.
std::uint64_t get_time_passed() const noexcept
Time passed in milliseconds.
bool stopped() const
Is the Stopwatch finished?
Asynchronous timer class.
void stop() noexcept
Stop timer.
void pause(const bool pause) noexcept
Pause the timer.
void start(const bool repeat=false)
Start timer.
bool paused() const noexcept
Is the timer paused?
bool stopped() const noexcept
Is the timer finished?
std::uint64_t ms_to_ns(const std::uint64_t ms) noexcept
Converts milliseconds to nanoseconds.
void delay(const int milli) noexcept
Delay the current thread for x time.
std::uint64_t s_to_ns(const std::uint64_t s) noexcept
Converts seconds to nanoseconds.
std::uint64_t us_to_ns(const std::uint64_t us) noexcept
Converts microseconds to nanoseconds.
std::uint64_t ns_to_ms(const std::uint64_t ns) noexcept
Converts nanoseconds to milliseconds.
std::uint64_t ns_to_us(const std::uint64_t ns) noexcept
Converts nanoseconds to microseconds.
void dt(const double dt) noexcept
Set galaxy delta time.
auto now() noexcept -> std::chrono::local_time< std::chrono::system_clock::duration >
Current local time.
std::uint64_t ns_to_s(const std::uint64_t ns) noexcept
Converts nanoseconds to seconds.
std::uint64_t time_since_epoch() noexcept
Time since epoch.