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