VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Clock.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace VoltMod
7{
8
9/**
10 * @brief The engine's simulation clock, read straight from IVEngineServer2::GetServerGlobals().
11 *
12 * Holds no state of its own - every call reads the engine live. It is the timestamp source for
13 * anything that must line up with the tick the engine is simulating. Both readings reset when a
14 * map starts, so never persist a value across a map change.
15 *
16 * Exposed as `runtime.Clock`.
17 */
18class Clock
19{
20public:
21 /** @p interfaces supplies IVEngineServer2; it must outlive this service. */
22 explicit Clock(Interfaces& interfaces);
23 Clock(const Clock&) = delete;
24 Clock& operator=(const Clock&) = delete;
25
26 /** The engine's CGlobalVars, or nullptr before load / after shutdown. */
27 CGlobalVars* Globals() const;
28
29 /** Current simulation tick (`tickcount`), or 0 when the globals are unavailable. */
30 int Tick() const;
31
32 /** Current simulation time in seconds (`curtime`), or 0 when the globals are unavailable. */
33 float Time() const;
34
35private:
36 Interfaces& _interfaces;
37};
38
39} // namespace VoltMod
The engine's simulation clock, read straight from IVEngineServer2::GetServerGlobals().
Definition Clock.hpp:19
Clock(const Clock &)=delete
Clock & operator=(const Clock &)=delete
float Time() const
Definition Clock.cpp:21
int Tick() const
Definition Clock.cpp:15
CGlobalVars * Globals() const
Definition Clock.cpp:10
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
Centralized holder for all HL2SDK interface pointers.