// Copyright (c) 2023 Dominic Masters
// 
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT

#include "DawnGame.hpp"
#include "scenes/TicTacToeScene.hpp"

using namespace Dawn;

DawnGame::DawnGame(DawnHost *host) :
  host(host),
  renderManager(this),
  inputManager(this),
  localeManager(this),
  saveManager(this)
{
}

int32_t DawnGame::init() {
  this->assetManager.init();
  this->localeManager.init();
  this->renderManager.init();

  this->scene = new TicTacToeScene(this);
  
  return DAWN_GAME_INIT_RESULT_SUCCESS;
}

int32_t DawnGame::update(float_t delta) {
  this->assetManager.update();
  this->inputManager.update();
  this->timeManager.update(delta);

  if(this->scene != nullptr) this->scene->update();
  
  this->renderManager.update();

  return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}

void DawnGame::sceneCutover(Scene *scene) {
  if(scene == nullptr) scene = this->scene;
  this->sceneToCutTo = scene;
}