// Copyright (c) 2022 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "dawnlibs.hpp" #include "scene/Scene.hpp" #include "display/RenderManager.hpp" #include "asset/AssetManager.hpp" #include "input/InputManager.hpp" #include "time/TimeManager.hpp" #include "input/InputBinds.hpp" #include "locale/LocaleManager.hpp" #include "save/SaveManager.hpp" // #include "scene/SceneItemComponentList.hpp" #define DAWN_GAME_INIT_RESULT_SUCCESS 0 #define DAWN_GAME_UPDATE_RESULT_SUCCESS 0 #define DAWN_GAME_UPDATE_RESULT_EXIT 1 namespace Dawn { class DawnHost; class DawnGame { private: Scene *sceneToCutTo = nullptr; public: DawnHost *host; Scene *scene = nullptr; AssetManager assetManager; TimeManager timeManager; RenderManager renderManager; InputManager inputManager; SaveManager saveManager; /** * Construct a new game instance. * * @param host Host that executed this game instantiation. */ DawnGame(DawnHost *host); /** * Initialize the game. This is performed by the host at a time that is * deemed to have the host ready for the game's initialization. This will * return an initialize result, where DAWN_GAME_INIT_RESULT_SUCCESS is * the only "successful" result, anything else is deemed a failure state. * * @param host Pointer to the host that is running this game. * @return The game initialize result. */ int32_t init(); /** * Performs a game update operation. This operation should occur exactly * once per frame, synchronously on the main thread. Updates can only * have two valid exit results, either DAWN_GAME_UPDATE_RESULT_SUCCESS for * a successful update, and request that we continue to update, or * DAWN_GAME_UPDATE_RESULT_EXIT for a successful update but to request * that no more update operations occur. Any other result is considered a * failure state. * * @param delta Time delta to tick the game by. * @return The game update result. */ int32_t update(float_t delta); /** * Changes to a new scene, will dispose the currently active scene as part * of that process. This assumes the other scene has already been loaded * and staged. * * @param scene Scene to cut over to. */ void sceneCutover(Scene *scene); }; /** * Unimplemented by default, required by the game as the basic entry point * for which scene should be used by default. * * @param game Game that is requesting this scene. * @return Pointer to a scene that you wish to have as the default scene. */ Scene * dawnGameGetInitialScene(DawnGame *game); }