package wow.doge.mygame.game.subsystems.level

import com.jme3.bullet.PhysicsSpace
import com.jme3.bullet.control.RigidBodyControl
import com.jme3.light.AmbientLight
import com.jme3.light.DirectionalLight
import com.jme3.scene.Node
import com.jme3.scene.Spatial
import com.softwaremill.tagging._
import monix.bio.Task
import wow.doge.mygame.game.GameAppTags
import wow.doge.mygame.implicits._

class GameLevel(
    model: Spatial,
    physicsControl: RigidBodyControl,
    ambientLight: AmbientLight,
    directionalLight: DirectionalLight
) {
  def addToGame(
      rootNode: Node @@ GameAppTags.RootNode,
      physicsSpace: PhysicsSpace
  ) = {
    for {
      _ <- Task(rootNode += model)
      _ <- Task(rootNode :+ ambientLight)
      _ <- Task(rootNode :+ directionalLight)
      _ <- Task(physicsSpace += model)
      _ <- Task(physicsSpace += physicsControl)
    } yield ()
  }
}
