-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.hpp
More file actions
executable file
·111 lines (88 loc) · 2.96 KB
/
Engine.hpp
File metadata and controls
executable file
·111 lines (88 loc) · 2.96 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#pragma once
#include <functional>
#include <optional>
#include <memory>
#include "Memory/BlockAllocator.hpp"
#include "Tools/ConsoleVar.hpp"
struct NeuralNetworkManager;
class Scene;
class IGame;
class SdlManager;
class Input;
class Console;
class PlotManager;
class MetricsManager;
class Renderer;
class SceneManager;
class SoundManager;
struct ServerGame;
struct ClientGame;
void ExecuteOnGameThread(const std::function<void()>& function);
struct EngineConfig
{
EngineConfig& SaveConsoleVarsToFile(const std::string& fileName)
{
consoleVarsFile = fileName;
return *this;
}
int blockAllocatorSizeBytes = 32 * 1024 * 1024;
std::optional<std::string> consoleVarsFile = "vars.cfg";
std::string initialConsoleCmd;
};
class Engine
{
public:
explicit Engine(const EngineConfig& config);
~Engine();
Input* GetInput() { return _input; }
SdlManager* GetSdlManager() { return _sdlManager.get(); }
Console* GetConsole() { return _console.get(); }
PlotManager* GetPlotManager() { return _plotManager.get(); }
MetricsManager* GetMetricsManager() { return _metricsManager.get(); }
Renderer* GetRenderer() { return _renderer.get(); }
BlockAllocator* GetDefaultBlockAllocator() { return _defaultBlockAllocator.get(); }
SoundManager* GetSoundManager() { return _soundManager.get(); }
ServerGame* GetServerGame() { return _serverGame.get(); }
ClientGame* GetClientGame() { return _clientGame.get(); }
NeuralNetworkManager* GetNeuralNetworkManager() { return _neuralNetworkManager.get(); }
bool ActiveGame() { return _activeGame; }
void QuitGame() { _activeGame = false; }
void SetGame(IGame* game);
IGame* Game() { return _game; }
void RunFrame();
bool IsPaused() const { return isPaused; }
void PauseGame();
void ResumeGame();
void SetLoadResources(const std::function<void()>& loadResources)
{
_loadResources = loadResources;
ReloadResources();
}
void ReloadResources()
{
_loadResources();
}
void StartServer(int port, const char* mapName);
void ConnectToServer(const char* address, int port);
void StartLocalServer(int port, const char* mapName);
void StartSinglePlayerGame(const char* mapName);
private:
Engine() = default;
bool isPaused = false;
Input* _input;
std::unique_ptr<SdlManager> _sdlManager;
std::unique_ptr<Console> _console;
std::unique_ptr<PlotManager> _plotManager;
std::unique_ptr<MetricsManager> _metricsManager;
std::unique_ptr<Renderer> _renderer;
std::unique_ptr<BlockAllocator> _defaultBlockAllocator;
std::unique_ptr<SoundManager> _soundManager;
std::unique_ptr<NeuralNetworkManager> _neuralNetworkManager;
std::shared_ptr<ServerGame> _serverGame;
std::shared_ptr<ClientGame> _clientGame;
IGame* _game = nullptr;
bool _activeGame = true;
EngineConfig _config;
std::function<void()> _loadResources;
};
extern ConsoleVar<bool> g_developerMode;