#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/FluidGrid.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;
  fluidActor = new Actor(scene);
  fluidActor->getTransform().setScale(Vector(20, 20, 20));

  auto& grid = fluidActor->attachComponent<Component::FluidGrid>();
  grid.viscosity = 0.1f;
  grid.diffusion = 0.1f;
  grid.gridSize = {256, 256, 256};
  grid.enableGravity = true;
  grid.gravity = Vector(10, 0, 0);
  // grid.enableGravity = false;
}

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

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