#include "FluidSimulationGame.h"
#include "Actor/CameraActor.h"
#include "Actor/DirectionalLightActor.h"
#include "Actor/PointLightActor.h"
#include "Actor/StaticMeshActor.h"
#include "Asset/AssetRegistry.h"
#include "Component/KeyboardInput.h"
#include "System/FlyCamSystem.h"

using namespace Seele;

FluidSimulationGame::FluidSimulationGame() {}

FluidSimulationGame::~FluidSimulationGame() {}

void FluidSimulationGame::setupScene(Seele::PScene scene, Seele::PSystemGraph graph) {
  graph->addSystem(new FlyCamSystem(scene));
  mesh = new StaticMeshActor(scene, AssetRegistry::findMesh("rttest", "rttest"));
  sun = new DirectionalLightActor(scene, Vector(1, -1, 1), 1, Vector(1, 1, 1));
  pointLight = new PointLightActor(scene, Vector(0, 1, 0), 1, Vector(1, 1, 1), 10);
  cam = new CameraActor(scene);
  cam->attachComponent<Component::KeyboardInput>();
  cam->getCameraComponent().mainCamera = true;

  Seele::Component::Transform transform;
  Seele::Component::FluidGrid grid;
  grid.cellSize = 0.1f;
  grid.viscosity = 0.001f;
  grid.diffusion = 0.0001f;
  grid.gridSize = {16, 16, 16};
  transform.transform.setPosition({0.0f, 0.0f, 0.0f});
  scene->getFluidScene()->updateFluidData(0, transform, grid);
}

extern "C" FluidSimulationGame *createInstance() { return new FluidSimulationGame(); }

extern "C" void destroyInstance(FluidSimulationGame *game) { delete game; }