blob: 08e5005c1b8f47080de6275ef53f6aa8b931de74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/* Starshatter: The Open Source Project
Copyright (c) 2021-2024, Starshatter: The Open Source Project Contributors
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
*/
#ifndef Clock_h
#define Clock_h
#include <chrono>
#include <cstdint>
class Clock
{
public:
using inner_clock = std::chrono::high_resolution_clock;
static Clock* GetInstance();
static bool Init();
static void Close();
void Set();
double Step();
void ResetGameTime(double seconds={});
void SkipGameTime(double seconds);
double Delta() const;
double GuiDelta() const;
double Rate() const;
double TimeCompression() const;
template <typename R = std::uint32_t> R GameTime() const;
template <typename R = std::uint32_t> R RealTime() const;
void SetTimeCompression(double compression);
protected:
Clock();
inner_clock::time_point m_point;
inner_clock::duration m_game_elapsed;
inner_clock::duration m_real_elapsed;
double m_compression;
double m_delta;
double m_gui_delta;
double m_rate;
private:
static Clock* instance;
};
#include "Clock.inl.h"
#endif // Clock_h
|