105 lines
3.6 KiB
C++
105 lines
3.6 KiB
C++
#pragma once
|
|
#include "scripting/ScriptEngine.h"
|
|
#include "HotReload.h"
|
|
#include "gui/GuiManager.h"
|
|
#include "raylib.h"
|
|
#include "ShaderManager.h"
|
|
#include "ModelManager.h"
|
|
#include "MaterialManager.h"
|
|
#include "AssetManager.h"
|
|
#include "TextureManager.h"
|
|
#include "InputManager.h"
|
|
#include <entt.hpp>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
class Application {
|
|
public:
|
|
Application();
|
|
~Application();
|
|
|
|
bool Initialize(int argc, char* argv[]);
|
|
void Run();
|
|
void Shutdown();
|
|
void RequestShutdown() { queueShutdown = true; }
|
|
|
|
bool IsEditorEnabled() const { return enableEditor; }
|
|
bool HasScriptCompilationError() const { return scriptCompilationError; }
|
|
entt::registry& GetRegistry() { return registry; }
|
|
AssetManager& GetAssetManager() { return assetManager; }
|
|
InputManager& GetInputManager() { return inputManager; }
|
|
Camera3D& GetEditorCamera() { return editorCamera; }
|
|
bool IsUsingEditorCamera() const { return useEditorCamera; }
|
|
void SetUseEditorCamera(bool enabled) { useEditorCamera = enabled; }
|
|
|
|
private:
|
|
struct EntityScriptModule {
|
|
std::string path;
|
|
std::string moduleName;
|
|
asIScriptModule* module = nullptr;
|
|
// For object-instance based entity scripts we cache the object type
|
|
// (stored opaquely here to avoid requiring the AngelScript headers
|
|
// in all translation units) and the object-methods (Init/Update/Shutdown)
|
|
// to avoid repeated lookups.
|
|
asITypeInfo* objectType = nullptr;
|
|
std::string objectTypeName;
|
|
asIScriptFunction* initFunc = nullptr; // object method: Init(uint)
|
|
asIScriptFunction* updateFunc = nullptr; // object method: Update(uint,float)
|
|
asIScriptFunction* shutdownFunc = nullptr;// object method: Shutdown(uint)
|
|
bool valid = false;
|
|
};
|
|
|
|
struct SceneScriptInstance {
|
|
asIScriptObject* instance = nullptr;
|
|
std::string className;
|
|
asIScriptFunction* initFunc = nullptr;
|
|
asIScriptFunction* updateFunc = nullptr;
|
|
asIScriptFunction* shutdownFunc = nullptr;
|
|
};
|
|
|
|
ScriptEngine scriptEngine;
|
|
HotReload* hotReload;
|
|
bool scriptCompilationError;
|
|
struct PHYSFS_File* logFile;
|
|
GuiManager guiManager;
|
|
bool enableEditor;
|
|
bool queueShutdown = false;
|
|
RenderTexture2D renderTexture; // renderTexture for Raylib rendering
|
|
|
|
// ECS
|
|
entt::registry registry;
|
|
|
|
// Resource managers
|
|
ShaderManager shaderManager;
|
|
ModelManager modelManager;
|
|
MaterialManager materialManager;
|
|
AssetManager assetManager;
|
|
TextureManager textureManager;
|
|
InputManager inputManager;
|
|
std::unordered_map<std::string, EntityScriptModule> entityScriptModules;
|
|
std::unordered_map<entt::entity, std::string> entityScriptBindings;
|
|
unsigned int entityScriptModuleCounter = 0;
|
|
std::string currentSceneScriptPath;
|
|
SceneScriptInstance sceneScriptInstance;
|
|
Camera3D editorCamera;
|
|
bool useEditorCamera = false;
|
|
|
|
static const int WINDOW_WIDTH = 1280;
|
|
static const int WINDOW_HEIGHT = 720;
|
|
static const int TARGET_FPS = 60;
|
|
static const char* WINDOW_TITLE;
|
|
|
|
void Update(float deltaTime);
|
|
void UpdateSystems(float deltaTime);
|
|
void UpdateEntityScripts(float deltaTime);
|
|
void ShutdownEntityScripts();
|
|
bool ProcessSceneScriptChanges();
|
|
void ReloadEntityScriptModules();
|
|
EntityScriptModule* GetEntityScriptModule(const std::string& path);
|
|
void InitializeSceneScriptInstance();
|
|
void ShutdownSceneScriptInstance();
|
|
void CallSceneUpdate(float deltaTime);
|
|
void RenderScene();
|
|
void Draw();
|
|
bool RunAutoloadScript(bool abortOnFailure);
|
|
}; |