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 Manager;
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
63 struct CreateInfo {
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 Grindstone::Plugins::BaseEditorInterface* editorPluginInterface = nullptr;
71 };
72
73 bool Initialize(CreateInfo& ci);
74 virtual void LoadPluginList();
75 virtual void InitializeScene(bool shouldLoadSceneFromDefaults, const char* scenePath = nullptr);
76 virtual void ShowMainWindow();
77
78 virtual ~EngineCore();
79 virtual void Run();
80 virtual void RunEditorLoopIteration();
81 virtual void RunLoopIteration();
82 virtual void UpdateWindows();
83 void RegisterGraphicsCore(GraphicsAPI::Core*);
84 virtual void RegisterInputManager(Input::Interface*);
85 virtual void SetRendererFactory(BaseRendererFactory* factory);
86 virtual Input::Interface* GetInputManager() const;
87 virtual SceneManagement::SceneManager* GetSceneManager() const;
88 virtual Plugins::Manager* GetPluginManager() const;
89 virtual ECS::SystemRegistrar* GetSystemRegistrar() const;
90 virtual Events::Dispatcher* GetEventDispatcher() const;
91 virtual ECS::ComponentRegistrar* GetComponentRegistrar() const;
92 virtual GraphicsAPI::Core* GetGraphicsCore() const;
93 virtual Profiler::Manager* GetProfiler() const;
94 virtual BaseRendererFactory* GetRendererFactory() const;
95 virtual RenderPassRegistry* GetRenderPassRegistry() const;
96 virtual WorldContextManager* GetWorldContextManager() const;
97 virtual std::filesystem::path GetProjectPath() const;
98 virtual std::filesystem::path GetBinaryPath() const;
99 virtual std::filesystem::path GetEngineBinaryPath() const;
100 virtual std::filesystem::path GetAssetsPath() const;
101 virtual std::filesystem::path GetEngineAssetsPath() const;
102 virtual std::filesystem::path GetAssetPath(std::string subPath) const;
103 virtual entt::registry& GetEntityRegistry();
104 virtual void ReloadCsharpBinaries();
105
106 virtual bool OnTryQuit(Grindstone::Events::BaseEvent* ev);
107 virtual bool OnForceQuit(Grindstone::Events::BaseEvent* ev);
108 virtual void CalculateDeltaTime();
109 virtual double GetTimeSinceLaunch() const;
110 virtual double GetDeltaTime() const;
111 public:
112 DisplayManager* displayManager = nullptr;
113 WindowManager* windowManager = nullptr;
114 Assets::AssetManager* assetManager = nullptr;
115 AssetRendererManager* assetRendererManager = nullptr;
116 WorldContextManager* worldContextManager = nullptr;
117 Profiler::Manager* profiler = nullptr;
118 std::function<void()> callbackReloadCsharp;
119 bool isEditor = false;
120 private:
121 double currentTime = 0.0;
122 double deltaTime = 0.0;
123 std::chrono::steady_clock::time_point firstFrameTime;
124 std::chrono::steady_clock::time_point lastFrameTime;
125 SceneManagement::SceneManager* sceneManager = nullptr;
126 ECS::ComponentRegistrar* componentRegistrar = nullptr;
127 ECS::SystemRegistrar* systemRegistrar = nullptr;
128 BaseRendererFactory* rendererFactory = nullptr;
129 RenderPassRegistry* renderpassRegistry = nullptr;
130 Events::Dispatcher* eventDispatcher = nullptr;
131 Plugins::Manager* pluginManager = nullptr;
132 GraphicsAPI::Core* graphicsCore = nullptr;
133 Input::Interface* inputManager = nullptr;
134 bool shouldClose = false;
135 std::filesystem::path projectPath;
136 std::filesystem::path binaryPath;
137 std::filesystem::path engineBinaryPath;
138 std::filesystem::path engineAssetsPath;
139 std::filesystem::path assetsPath;
140 };
141}
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 Interface.hpp:42
Definition Manager.hpp:16
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 BaseEvent.hpp:7