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

#include "sandboxscene.h"

bool sandboxSceneInit(sandboxscene_t *game) {
  // Init Scripter
  scripterInit(&game->scripter, &game->engine);
  game->scripter.user = game;

  // Add APIs
  scriptsApiIo(&game->scripter);
  scriptsApiDisplay(&game->scripter);
  scriptsApiAsset(&game->scripter);
  scriptsApiEpoch(&game->scripter);

  // Load main script
  assetScripterAppend(&game->scripter, "scripts/main.js");

  // Invoke initialization.
  scripterInvokeMethodSimple(&game->scripter, "init");

  return true;
}

void sandboxSceneUpdate(sandboxscene_t *game) {
  scripterInvokeMethodSimple(&game->scripter, "update");
}

void sandboxSceneDispose(sandboxscene_t *game) {
  scripterInvokeMethodSimple(&game->scripter, "dispose");
}