vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
engine.h
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <memory>
6#include <vector>
7
8#include "ecs/scene.h"
9#include "resource/resource_manager.h"
10#include "platform/window/window_manager.h"
11#include "core/system.h"
12#include "system/render/render_settings.h"
13#include "core/clock.h"
14#include "core/event/event_bus.h"
15#include "core/host_chrome.h"
16#include "platform/input/input_map.h"
17#include "net/net_session.h"
18
19namespace Vkm::Engine {
20
27class Engine {
28 public:
29 Engine();
30 ~Engine();
31
32 Engine(const Engine& other) = delete;
33 Engine& operator=(const Engine& other) = delete;
34
35 Engine(Engine && other) = delete;
36 Engine& operator=(Engine && other) = delete;
37
38 public:
44 void setFPSLog(bool enabled = true) { m_fpsLog = enabled; }
45
49 void run();
50
62 template<typename T, typename... Args>
63 T& addSystem(SystemStage stage, Args&&... args) {
64 auto system = std::make_unique<T>(std::forward<Args>(args)...);
65 T& ref = *system;
66 m_systemsByStage[static_cast<size_t>(stage)].push_back(std::move(system));
67 return ref;
68 }
69
70 Scene& getScene() { return m_scene; }
71 const Scene& getScene() const { return m_scene; }
72
73 ResourceManager& getResources() { return m_resources; }
74 const ResourceManager& getResources() const { return m_resources; }
75
76 Clock& getClock() { return m_clock; }
77 const Clock& getClock() const { return m_clock; }
78
79 EventBus& getEvents() { return m_events; }
80 const EventBus& getEvents() const { return m_events; }
81
87 InputMap& getInput() { return m_input; }
88 const InputMap& getInput() const { return m_input; }
89
90 WindowManager& getWindow() { return m_window; }
91 const WindowManager& getWindow() const { return m_window; }
92
98 HostChrome& getChrome() { return m_chrome; }
99 const HostChrome& getChrome() const { return m_chrome; }
100
107 RenderSettings& getRenderSettings() { return m_render; }
108 const RenderSettings& getRenderSettings() const { return m_render; }
109
117 m_projectRender = project;
118 m_render = project;
119 }
120
122 const RenderSettings& getProjectRenderSettings() const { return m_projectRender; }
123
130 NetSession& getNet() { return m_net; }
131 const NetSession& getNet() const { return m_net; }
132
133 private:
134 using SystemList = std::vector<std::unique_ptr<System>>;
135
136 void initSystems(FrameContext& ctx);
137 void shutdownSystems();
138
139 private:
142 EventBus m_events;
143
144 Scene m_scene;
145 ResourceManager m_resources;
146
147 Clock m_clock;
148 InputMap m_input;
149 WindowManager m_window;
150 NetSession m_net;
151 HostChrome m_chrome;
152 RenderSettings m_render;
153 RenderSettings m_projectRender;
154
155 std::array<SystemList, static_cast<size_t>(SystemStage::Count)> m_systemsByStage;
156
157 bool m_initialized = false;
158 bool m_fpsLog = false;
159};
160
161} // namespace Vkm::Engine
const RenderSettings & getProjectRenderSettings() const
The project.json render block the session started from (setProjectRenderSettings).
Definition engine.h:122
InputMap & getInput()
The action map gameplay reads input through.
Definition engine.h:87
NetSession & getNet()
The session this end is playing in, offline until told otherwise.
Definition engine.h:130
void setFPSLog(bool enabled=true)
Log "FPS: N (M ms)" to the console once a second.
Definition engine.h:44
RenderSettings & getRenderSettings()
The quality settings this session draws at.
Definition engine.h:107
T & addSystem(SystemStage stage, Args &&... args)
Create and register a system at the given execution stage.
Definition engine.h:63
void setProjectRenderSettings(const RenderSettings &project)
Start the session from project, the project.json render block: the session's settings and the copy ga...
Definition engine.h:116
HostChrome & getChrome()
What an authoring host says about the frame it draws over.
Definition engine.h:98
void run()
Run the main loop, blocking until the window closes or the process is interrupted.
What an authoring host tells the engine about the frame it draws over.
Definition host_chrome.h:18
Named actions resolved from physical bindings, sampled once per frame.
Definition input_map.h:79
One end of a game, whether it is the authority or a guest.
Definition net_session.h:118
Central registry managing entities and an open set of component types.
Definition scene.h:29
Editable render tuning: pass toggles + per-effect parameters.
Definition render_settings.h:101