Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
EngineCore.hpp
1#pragma once
2
3#include <filesystem>
4#include <functional>
5#include <chrono>
6
7#include <entt/entity/registry.hpp>
8
9#include <Common/Logging.hpp>
10
11namespace Grindstone {
12 namespace GraphicsAPI {
13 class Core;
14 class RenderPass;
15 }
16
17 namespace Input {
18 class Interface;
19 }
20
21 namespace Plugins {
22 class IPluginManager;
23 class Interface;
24 }
25
26 namespace ECS {
28 class SystemRegistrar;
29 }
30
31 namespace SceneManagement {
32 class SceneManager;
33 }
34
35 namespace Events {
36 struct BaseEvent;
37 class Dispatcher;
38 }
39
40 namespace Assets {
41 class AssetManager;
42 class AssetLoader;
43 }
44
45 namespace Profiler {
46 class Manager;
47 }
48
49 class Window;
50 class DisplayManager;
51 class WindowManager;
52
57
58 class EngineCore {
59 public:
60 static EngineCore& GetInstance();
61 static void SetInstance(EngineCore& engineCore);
62
64 bool isEditor = false;
65 const char* applicationModuleName = nullptr;
66 const char* applicationTitle = nullptr;
67 const char* projectPath = nullptr;
68 const char* engineBinaryPath = nullptr;
69 Assets::AssetLoader* assetLoader = nullptr;
70 };
71
73 Grindstone::Assets::AssetLoader* assetLoader = nullptr;
74 Grindstone::Plugins::IPluginManager* pluginManagerOverride = nullptr;
75 };
76
77 virtual bool EarlyInitialize(EarlyCreateInfo& ci);
78 virtual bool Initialize(LateCreateInfo& createInfo);
79 virtual void InitializeScene(bool shouldLoadSceneFromDefaults, const char* scenePath = nullptr);
80 virtual void ShowMainWindow();
81
82 virtual ~EngineCore();
83 virtual void Run();
84 virtual void RunEditorLoopIteration();
85 virtual void RunLoopIteration();
86 virtual void UpdateWindows();
87 void RegisterGraphicsCore(GraphicsAPI::Core*);
88 virtual void RegisterInputManager(Input::Interface*);
89 virtual void SetRendererFactory(BaseRendererFactory* factory);
90 virtual Input::Interface* GetInputManager() const;
91 virtual SceneManagement::SceneManager* GetSceneManager() const;
92 virtual Plugins::IPluginManager* GetPluginManager() const;
93 virtual Plugins::Interface* GetPluginInterface() const;
94 virtual ECS::SystemRegistrar* GetSystemRegistrar() const;
95 virtual Events::Dispatcher* GetEventDispatcher() const;
96 virtual ECS::ComponentRegistrar* GetComponentRegistrar() const;
97 virtual GraphicsAPI::Core* GetGraphicsCore() const;
98 virtual Profiler::Manager* GetProfiler() const;
99 virtual BaseRendererFactory* GetRendererFactory() const;
100 virtual RenderPassRegistry* GetRenderPassRegistry() const;
101 virtual WorldContextManager* GetWorldContextManager() const;
102 virtual std::filesystem::path GetProjectPath() const;
103 virtual std::filesystem::path GetBinaryPath() const;
104 virtual std::filesystem::path GetEngineBinaryPath() const;
105 virtual std::filesystem::path GetAssetsPath() const;
106 virtual std::filesystem::path GetEngineAssetsPath() const;
107 virtual std::filesystem::path GetAssetPath(std::string subPath) const;
108 virtual entt::registry& GetEntityRegistry();
109 virtual void ReloadCsharpBinaries();
110
111 virtual bool OnTryQuit(Grindstone::Events::BaseEvent* ev);
112 virtual bool OnForceQuit(Grindstone::Events::BaseEvent* ev);
113 virtual void CalculateDeltaTime();
114 virtual double GetTimeSinceLaunch() const;
115 virtual double GetDeltaTime() const;
116 public:
117 DisplayManager* displayManager = nullptr;
118 WindowManager* windowManager = nullptr;
119 Assets::AssetManager* assetManager = nullptr;
120 AssetRendererManager* assetRendererManager = nullptr;
121 WorldContextManager* worldContextManager = nullptr;
122 Profiler::Manager* profiler = nullptr;
123 std::function<void()> callbackReloadCsharp;
124 bool isEditor = false;
125 private:
126 double currentTime = 0.0;
127 double deltaTime = 0.0;
128 std::chrono::steady_clock::time_point firstFrameTime;
129 std::chrono::steady_clock::time_point lastFrameTime;
130 SceneManagement::SceneManager* sceneManager = nullptr;
131 ECS::ComponentRegistrar* componentRegistrar = nullptr;
132 ECS::SystemRegistrar* systemRegistrar = nullptr;
133 BaseRendererFactory* rendererFactory = nullptr;
134 RenderPassRegistry* renderpassRegistry = nullptr;
135 Events::Dispatcher* eventDispatcher = nullptr;
136 Plugins::Interface* pluginInterface = nullptr;
137 Plugins::IPluginManager* pluginManager = nullptr;
138 GraphicsAPI::Core* graphicsCore = nullptr;
139 Input::Interface* inputManager = nullptr;
140 bool shouldClose = false;
141 std::filesystem::path projectPath;
142 std::filesystem::path binaryPath;
143 std::filesystem::path engineBinaryPath;
144 std::filesystem::path engineAssetsPath;
145 std::filesystem::path assetsPath;
146 };
147}
Definition AssetRendererManager.hpp:18
Definition AssetLoader.hpp:32
Definition AssetManager.hpp:15
Definition BaseRenderer.hpp:42
Definition DisplayManager.hpp:8
Definition ComponentRegistrar.hpp:18
Definition SystemRegistrar.hpp:12
Definition EngineCore.hpp:58
Definition Dispatcher.hpp:14
Definition Core.hpp:29
Definition RenderPass.hpp:27
Definition InputInterface.hpp:11
Definition IPluginManager.hpp:9
Definition Interface.hpp:47
Definition Profiling.hpp:24
Definition RenderPassRegistry.hpp:12
Definition WindowManager.hpp:7
Definition Window.hpp:12
Definition WorldContextManager.hpp:12
Definition EngineCore.hpp:63
Definition EngineCore.hpp:72
Definition BaseEvent.hpp:7