vkmEngine 1.0.0
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
116 NetSession& getNet() { return m_net; }
117 const NetSession& getNet() const { return m_net; }
118
119 private:
120 using SystemList = std::vector<std::unique_ptr<System>>;
121
122 void initSystems(FrameContext& ctx);
123 void shutdownSystems();
124
125 private:
128 EventBus m_events;
129
130 Scene m_scene;
131 ResourceManager m_resources;
132
133 Clock m_clock;
134 InputMap m_input;
135 WindowManager m_window;
136 NetSession m_net;
137 HostChrome m_chrome;
138 RenderSettings m_render;
139
140 std::array<SystemList, static_cast<size_t>(SystemStage::Count)> m_systemsByStage;
141
142 bool m_initialized = false;
143 bool m_fpsLog = false;
144};
145
146} // namespace Vkm::Engine
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:116
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
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:64
One end of a game, whether it is the authority or a guest.
Definition net_session.h:116
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:86