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.
 
 

59 lines
1.9 KiB

// package wow.doge.mygame.subsystems.events
// import akka.actor.typed.ActorRef
// import akka.actor.typed.SpawnProtocol
// import wow.doge.mygame.implicits._
// import akka.actor.typed.Props
// import akka.actor.typed.LogOptions
// import com.typesafe.scalalogging.{Logger => SLLogger}
// import wow.doge.mygame.events.EventBus
// import akka.actor.typed.scaladsl.Behaviors
// import wow.doge.mygame.events.Events
// import cats.effect.Resource
// import monix.bio.Task
// import akka.actor.typed.ActorSystem
// import scala.concurrent.duration._
// trait EventsModule2 {
// def eventBusesResource(
// spawnProtocol: ActorSystem[SpawnProtocol.Command],
// eventBusLogger: com.typesafe.scalalogging.Logger = SLLogger[EventBus[_]]
// ): Resource[
// Task,
// (
// ActorRef[EventBus.Command[Events.Tick]],
// ActorRef[EventBus.Command[Events.Movement.PlayerMovement]]
// )
// ] = {
// def createEventBus[T](busName: String) =
// spawnProtocol.askL(
// SpawnProtocol.Spawn[EventBus.Command[T]](
// Behaviors.logMessages(
// logOptions = LogOptions().withLogger(eventBusLogger.underlying),
// EventBus[T]()
// ),
// busName,
// Props.empty,
// _
// )
// )(1.second, spawnProtocol.scheduler)
// Resource.liftF {
// {
// lazy val tickEventBusTask = createEventBus[Events.Tick]("tickEventBus")
// lazy val playerMovementEventBusTask =
// createEventBus[Events.Movement.PlayerMovement]("movementEventBus")
// // val r = (tickEventBusTask, playerMovementEventBusTask)
// // Task(r)
// for {
// tickEventBus <- tickEventBusTask
// playerMovementEventBus <- playerMovementEventBusTask
// } yield (tickEventBus, playerMovementEventBus)
// }
// }
// }
// }