// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "dawn.hpp" #include "util/Flag.hpp" #include "display/RenderHost.hpp" #include "input/InputManager.hpp" #include "time/TimeManager.hpp" #include "asset/AssetManager.hpp" #include "locale/LocaleManager.hpp" #include "save/SaveManager.hpp" #include "settings/SettingsManager.hpp" #include "display/shader/ShaderManager.hpp" #ifdef DAWN_ENABLE_PHYSICS #include "physics/PhysicsManager.hpp" #endif namespace Dawn { class Scene; class Game; enum class GameState : flag_t { INITIAL = FLAG(0), INITIALIZED = FLAG(1), }; class IGame : public std::enable_shared_from_this { private: std::shared_ptr currentScene = nullptr; std::shared_ptr nextFrameScene = nullptr; flag_t state = (flag_t)GameState::INITIAL; protected: /** * Returns the initial scene for the game. Implemented by the main game * instance. * * @return The initial scene. */ virtual std::string getInitialScene() = 0; /** * Initializes the game managers. */ virtual void initManagers() = 0; /** * Returns the game instance as a Game instance. * * @return The game instance as a Game instance. */ std::shared_ptr getSelfAsGame(); public: std::shared_ptr renderHost; std::shared_ptr assetManager; std::shared_ptr localeManager; std::shared_ptr settingsManager; std::shared_ptr shaderManager; #ifdef DAWN_ENABLE_PHYSICS std::shared_ptr physicsManager; #endif InputManager inputManager; TimeManager timeManager; SaveManager saveManager; /** * Constructs the game instance, does not initialize anything. */ IGame(); /** * Initialize the game and all of its components. */ void init(); /** * Deinitialize the game and all of its components. */ void deinit(); /** * Performs a single update tick on the game engine, and in turn all of * the game's sub systems. */ void update(); /** * Returns whether the game has been requested to gracefully close at the * next available opportunity. * * @return True if the game should close. */ bool_t isCloseRequested(); /** * Returns the current scene that is active. * * @return The current scene. */ std::shared_ptr getCurrentScene(); /** * Deconstructs the game instance, does not deinitialize anything. */ virtual ~IGame(); }; }