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

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. package wow.doge.mygame.utils.wrappers.jme
  2. import com.jme3.{bullet => jmeb}
  3. import com.jme3.{scene => jmes}
  4. import monix.bio.UIO
  5. import wow.doge.mygame.implicits._
  6. final class PhysicsSpace(space: jmeb.PhysicsSpace) {
  7. def add(anyObject: Any) = UIO(space.add(anyObject))
  8. def remove(anyObject: Any) =
  9. UIO {
  10. space.remove(anyObject)
  11. space
  12. }
  13. def addAll(spatial: jmes.Spatial) = UIO(space.addAll(spatial))
  14. def removeAll(spatial: jmes.Spatial) =
  15. UIO {
  16. space.removeAll(spatial)
  17. space
  18. }
  19. def collisionObservable = space.collisionObservable()
  20. def physicsTickObservable = space.physicsTickObservable()
  21. }
  22. object PhysicsSpace {
  23. implicit final class PhysicsSpaceOps(private val space: PhysicsSpace)
  24. extends AnyVal {
  25. def +=(anyObject: Any) = space.add(anyObject)
  26. def :+(anyObject: Any) = {
  27. space.add(anyObject)
  28. space
  29. }
  30. def -(anyObject: Any) = {
  31. space.remove(anyObject)
  32. space
  33. }
  34. def -=(anyObject: Any) = space.remove(anyObject)
  35. def +=(spatial: jmes.Spatial) = space.addAll(spatial)
  36. def :+(spatial: jmes.Spatial) = {
  37. space.addAll(spatial)
  38. space
  39. }
  40. def -(spatial: jmes.Spatial) = {
  41. space.removeAll(spatial)
  42. space
  43. }
  44. def -=(spatial: jmes.Spatial) = space.removeAll(spatial)
  45. }
  46. }