Testing out JmonkeyEngine to make a game in Scala with Akka Actors within a pure FP layer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.3 KiB

package wow.doge.mygame.utils.wrappers.jme
import com.jme3.{bullet => jmeb}
import com.jme3.{scene => jmes}
import monix.bio.UIO
import wow.doge.mygame.implicits._
final class PhysicsSpace(space: jmeb.PhysicsSpace) {
def add(anyObject: Any) = UIO(space.add(anyObject))
def remove(anyObject: Any) =
UIO {
space.remove(anyObject)
space
}
def addAll(spatial: jmes.Spatial) = UIO(space.addAll(spatial))
def removeAll(spatial: jmes.Spatial) =
UIO {
space.removeAll(spatial)
space
}
def collisionObservable = space.collisionObservable()
def physicsTickObservable = space.physicsTickObservable()
}
object PhysicsSpace {
implicit final class PhysicsSpaceOps(private val space: PhysicsSpace)
extends AnyVal {
def +=(anyObject: Any) = space.add(anyObject)
def :+(anyObject: Any) = {
space.add(anyObject)
space
}
def -(anyObject: Any) = {
space.remove(anyObject)
space
}
def -=(anyObject: Any) = space.remove(anyObject)
def +=(spatial: jmes.Spatial) = space.addAll(spatial)
def :+(spatial: jmes.Spatial) = {
space.addAll(spatial)
space
}
def -(spatial: jmes.Spatial) = {
space.removeAll(spatial)
space
}
def -=(spatial: jmes.Spatial) = space.removeAll(spatial)
}
}