#pragma once #include "Nuake/Core/Core.h" #include "Nuake/Core/GameState.h" #include "Nuake/Core/Logger.h" #include "Nuake/Window.h" #include "Nuake/Core/MulticastDelegate.h" // Welcome to the Nuake source code. namespace Nuake { class Project; class Scene; class EngineSubsystem; class EngineSubsystemScriptable; class Engine { public: static void Init(); // Initialize the engine. static void Tick(); // Updates everything, called every frame. static void Close(); // Shutdown the engine. static void EnterPlayMode(); // Start the game static void ExitPlayMode(); // Stops the game // Custom drawing should happen in between these two static void Draw(); // Start new frame static void EndDraw(); // Swap buffer static void SetGameState(GameState state); static GameState GetGameState() { return gameState; } static bool IsPlayMode() { return gameState == GameState::Playing; } static inline float GetTime() { return time; } static inline Timestep GetTimestep() { return timeStep; } static inline void SetPhysicsStep(int amount) { fixedUpdateRate = 1.0f / static_cast(amount); } static inline float GetFixedTimeStep() { return fixedUpdateRate; } static inline void SetTimeScale(float timeScale) { timeScale = timeScale; } static inline float GetTimeScale() { return timeScale; } static Ref GetCurrentWindow(); static bool SetCurrentScene(Ref scene); static bool QueueSceneSwitch(const std::string& scene); static Ref GetCurrentScene(); static bool LoadProject(Ref project); static Ref GetProject(); static Ref GetScriptedSubsystem(const std::string& subsystemName); static Ref GetScriptedSubsystem(const int subsystemId); protected: static void OnWindowSetScene(Ref oldScene, Ref newScene); static void InitializeCoreSubsystems(); static void OnScriptingEngineUninitialize(); static void OnScriptingEngineGameAssemblyLoaded(); static void OnScenePreInitialize(Ref scene); static void OnScenePostInitialize(Ref scene); private: static Ref currentWindow; static Ref currentProject; static Ref currentScene; static std::string queuedScene; static inline std::vector> subsystems; static inline std::unordered_map> scriptedSubsystemMap; static GameState gameState; static float lastFrameTime; static float fixedUpdateRate; static float fixedUpdateDifference; static float time; static Timestep timeStep; static float timeScale; public: static MulticastDelegate> OnSceneLoaded; private: static void GenerateManifest(); }; }