Some Refactorings
This commit is contained in:
parent
88293cebde
commit
45ab129790
@ -1,6 +1,5 @@
|
|||||||
package wow.doge.mygame
|
package wow.doge.mygame
|
||||||
|
|
||||||
import akka.actor.typed.ActorRef
|
|
||||||
import akka.actor.typed.ActorSystem
|
import akka.actor.typed.ActorSystem
|
||||||
import akka.actor.typed.Scheduler
|
import akka.actor.typed.Scheduler
|
||||||
import akka.actor.typed.SpawnProtocol
|
import akka.actor.typed.SpawnProtocol
|
||||||
@ -31,7 +30,7 @@ import wow.doge.mygame.game.GameAppActor
|
|||||||
import wow.doge.mygame.game.GameAppTags
|
import wow.doge.mygame.game.GameAppTags
|
||||||
import wow.doge.mygame.game.entities.EntityIds
|
import wow.doge.mygame.game.entities.EntityIds
|
||||||
import wow.doge.mygame.game.entities.NpcActorSupervisor
|
import wow.doge.mygame.game.entities.NpcActorSupervisor
|
||||||
import wow.doge.mygame.game.entities.NpcMovementActor2
|
import wow.doge.mygame.game.entities.NpcMovementActor
|
||||||
import wow.doge.mygame.game.entities.PlayerController
|
import wow.doge.mygame.game.entities.PlayerController
|
||||||
import wow.doge.mygame.game.entities.PlayerControllerTags
|
import wow.doge.mygame.game.entities.PlayerControllerTags
|
||||||
import wow.doge.mygame.game.subsystems.input.GameInputHandler
|
import wow.doge.mygame.game.subsystems.input.GameInputHandler
|
||||||
@ -40,10 +39,8 @@ import wow.doge.mygame.implicits._
|
|||||||
import wow.doge.mygame.launcher.Launcher
|
import wow.doge.mygame.launcher.Launcher
|
||||||
import wow.doge.mygame.launcher.Launcher.LauncherResult
|
import wow.doge.mygame.launcher.Launcher.LauncherResult
|
||||||
import wow.doge.mygame.math.ImVector3f
|
import wow.doge.mygame.math.ImVector3f
|
||||||
import wow.doge.mygame.subsystems.events.EventBus
|
|
||||||
import wow.doge.mygame.subsystems.events.EventsModule
|
import wow.doge.mygame.subsystems.events.EventsModule
|
||||||
import wow.doge.mygame.subsystems.events.PlayerCameraEvent
|
import wow.doge.mygame.subsystems.events.PlayerEvent
|
||||||
import wow.doge.mygame.subsystems.events.PlayerMovementEvent
|
|
||||||
import wow.doge.mygame.subsystems.events.TickEvent
|
import wow.doge.mygame.subsystems.events.TickEvent
|
||||||
import wow.doge.mygame.subsystems.scriptsystem.ScriptInitMode
|
import wow.doge.mygame.subsystems.scriptsystem.ScriptInitMode
|
||||||
import wow.doge.mygame.subsystems.scriptsystem.ScriptSystemResource
|
import wow.doge.mygame.subsystems.scriptsystem.ScriptSystemResource
|
||||||
@ -71,12 +68,11 @@ class MainApp(
|
|||||||
def gameInit: Task[Fiber[Throwable, Unit]] =
|
def gameInit: Task[Fiber[Throwable, Unit]] =
|
||||||
for {
|
for {
|
||||||
eventsModule <- Task(new EventsModule(spawnProtocol))
|
eventsModule <- Task(new EventsModule(spawnProtocol))
|
||||||
playerMovementEventBus <- eventsModule.playerMovementEventBusTask
|
playerEventBus <- eventsModule.playerEventBusTask
|
||||||
playerCameraEventBus <- eventsModule.playerCameraEventBusTask
|
|
||||||
mainEventBus <- eventsModule.mainEventBusTask
|
mainEventBus <- eventsModule.mainEventBusTask
|
||||||
tickEventBus <- eventsModule.tickEventBusTask
|
tickEventBus <- eventsModule.tickEventBusTask
|
||||||
gameAppActor <- AkkaUtils.spawnActorL2(
|
gameAppActor <- AkkaUtils.spawnActorL2(
|
||||||
GameAppActor.Props(tickEventBus).create,
|
GameAppActor.Props(tickEventBus).behavior,
|
||||||
"gameAppActor"
|
"gameAppActor"
|
||||||
)
|
)
|
||||||
_ <- gameAppActor !! GameAppActor.Start
|
_ <- gameAppActor !! GameAppActor.Start
|
||||||
@ -152,10 +148,7 @@ class MainAppDelegate(
|
|||||||
gameApp: GameApp,
|
gameApp: GameApp,
|
||||||
implicit val spawnProtocol: ActorSystem[SpawnProtocol.Command],
|
implicit val spawnProtocol: ActorSystem[SpawnProtocol.Command],
|
||||||
loggerL: Logger[Task],
|
loggerL: Logger[Task],
|
||||||
playerMovementEventBus: ActorRef[
|
playerEventBus: GameEventBus[PlayerEvent],
|
||||||
EventBus.Command[PlayerMovementEvent]
|
|
||||||
],
|
|
||||||
playerCameraEventBus: ActorRef[EventBus.Command[PlayerCameraEvent]],
|
|
||||||
tickEventBus: GameEventBus[TickEvent],
|
tickEventBus: GameEventBus[TickEvent],
|
||||||
inputManager: InputManager,
|
inputManager: InputManager,
|
||||||
assetManager: AssetManager,
|
assetManager: AssetManager,
|
||||||
@ -275,7 +268,7 @@ class MainAppDelegate(
|
|||||||
// initialPos,
|
// initialPos,
|
||||||
// tickEventBus,
|
// tickEventBus,
|
||||||
// npcPhysicsControl
|
// npcPhysicsControl
|
||||||
// ).create,
|
// ).behavior,
|
||||||
// s"${npcName}-npcMovementActor"
|
// s"${npcName}-npcMovementActor"
|
||||||
// )
|
// )
|
||||||
lazy val mbNpcNode = PlayerController.Defaults.defaultNpcNode(
|
lazy val mbNpcNode = PlayerController.Defaults.defaultNpcNode(
|
||||||
@ -287,16 +280,16 @@ class MainAppDelegate(
|
|||||||
val npcActorTask = AkkaUtils.spawnActorL2(
|
val npcActorTask = AkkaUtils.spawnActorL2(
|
||||||
NpcActorSupervisor
|
NpcActorSupervisor
|
||||||
.Props(
|
.Props(
|
||||||
new NpcMovementActor2.Props(
|
new NpcMovementActor.Props(
|
||||||
enqueueR,
|
enqueueR,
|
||||||
initialPos,
|
initialPos,
|
||||||
// tickEventBus,
|
// tickEventBus,
|
||||||
npcPhysicsControl
|
npcPhysicsControl
|
||||||
).create,
|
).behavior,
|
||||||
npcName,
|
npcName,
|
||||||
initialPos
|
initialPos
|
||||||
)
|
)
|
||||||
.create,
|
.behavior,
|
||||||
s"${npcName}-npcActorSupervisor"
|
s"${npcName}-npcActorSupervisor"
|
||||||
)
|
)
|
||||||
// .taggedWith[PlayerControllerTags.PlayerTag]
|
// .taggedWith[PlayerControllerTags.PlayerTag]
|
||||||
|
@ -117,7 +117,7 @@ object SpawnSystem {
|
|||||||
final case object Complete extends Complete
|
final case object Complete extends Complete
|
||||||
|
|
||||||
sealed trait SpawnRequest
|
sealed trait SpawnRequest
|
||||||
final case class SpawnSpatial(node: Node) extends SpawnRequest
|
final case class SpawnSpatial(nodeTask: Task[Node]) extends SpawnRequest
|
||||||
|
|
||||||
final case class SpawnRequestWrapper(
|
final case class SpawnRequestWrapper(
|
||||||
spawnRequest: SpawnRequest,
|
spawnRequest: SpawnRequest,
|
||||||
@ -147,7 +147,7 @@ class SpawnSystem(
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
spawnSystem <- SpawnSystem(logger)
|
spawnSystem <- SpawnSystem(logger)
|
||||||
n <- spawnSystem.request(SpawnSpatial(new Node("Test")))
|
res <- spawnSystem.request(SpawnSpatial(Task(new Node("Test"))))
|
||||||
} yield ()
|
} yield ()
|
||||||
|
|
||||||
// val spawnChannel = ConcurrentChannel[Task].of[Result, SpawnRequest]
|
// val spawnChannel = ConcurrentChannel[Task].of[Result, SpawnRequest]
|
||||||
@ -164,18 +164,20 @@ class SpawnSystem(
|
|||||||
_ <- handleSpawn(message)
|
_ <- handleSpawn(message)
|
||||||
} yield receive(consumer)
|
} yield receive(consumer)
|
||||||
case Left(r) =>
|
case Left(r) =>
|
||||||
logger.info("Worker $$index is done!")
|
logger.info("Closing Spawn System")
|
||||||
}
|
}
|
||||||
|
|
||||||
private def handleSpawn(spawnRequestWrapper: SpawnRequestWrapper) =
|
private def handleSpawn(spawnRequestWrapper: SpawnRequestWrapper) =
|
||||||
spawnRequestWrapper match {
|
spawnRequestWrapper match {
|
||||||
case SpawnRequestWrapper(spawnRequest, result) =>
|
case SpawnRequestWrapper(spawnRequest, result) =>
|
||||||
spawnRequest match {
|
spawnRequest match {
|
||||||
case SpawnSpatial(spatial) =>
|
case SpawnSpatial(spatialTask) =>
|
||||||
logger.debug(
|
spatialTask.flatMap(spatial =>
|
||||||
s"Spawning spatial with name ${spatial.getName()}"
|
logger.debug(
|
||||||
) >> result
|
s"Spawning spatial with name ${spatial.getName()}"
|
||||||
.complete(Ok)
|
) >> result
|
||||||
|
.complete(Ok)
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ object GameAppActor {
|
|||||||
// loggerL: Logger[Task]
|
// loggerL: Logger[Task]
|
||||||
tickEventBus: GameEventBus[TickEvent]
|
tickEventBus: GameEventBus[TickEvent]
|
||||||
) {
|
) {
|
||||||
def create =
|
def behavior =
|
||||||
Behaviors.setup[Command] { ctx =>
|
Behaviors.setup[Command] { ctx =>
|
||||||
ctx.log.info("Hello from GameAppActor")
|
ctx.log.info("Hello from GameAppActor")
|
||||||
val renderTickGenerator =
|
val renderTickGenerator =
|
||||||
@ -40,7 +40,7 @@ object GameAppActor {
|
|||||||
val tickGeneratorTimer = ctx.spawn(
|
val tickGeneratorTimer = ctx.spawn(
|
||||||
GenericTimerActor
|
GenericTimerActor
|
||||||
.Props(renderTickGenerator, TickGenerator.Send, 10.millis)
|
.Props(renderTickGenerator, TickGenerator.Send, 10.millis)
|
||||||
.create,
|
.behavior,
|
||||||
"tickGeneratorTimer"
|
"tickGeneratorTimer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ object NpcActorSupervisor {
|
|||||||
final case class Move(pos: ImVector3f) extends Command
|
final case class Move(pos: ImVector3f) extends Command
|
||||||
private final case class InternalMove(
|
private final case class InternalMove(
|
||||||
move: Move,
|
move: Move,
|
||||||
signal: CancelableFuture[NpcMovementActor2.DoneMoving.type]
|
signal: CancelableFuture[NpcMovementActor.DoneMoving.type]
|
||||||
) extends Command
|
) extends Command
|
||||||
private case object DoneMoving extends Command
|
private case object DoneMoving extends Command
|
||||||
// private case class MovementResponse(response: CancelableFuture[_]) extends Command
|
// private case class MovementResponse(response: CancelableFuture[_]) extends Command
|
||||||
@ -40,11 +40,11 @@ object NpcActorSupervisor {
|
|||||||
private case object NoOp extends Command
|
private case object NoOp extends Command
|
||||||
|
|
||||||
final case class Props(
|
final case class Props(
|
||||||
npcMovementActorBehavior: Behavior[NpcMovementActor2.Command],
|
npcMovementActorBehavior: Behavior[NpcMovementActor.Command],
|
||||||
npcName: String,
|
npcName: String,
|
||||||
initialPos: ImVector3f
|
initialPos: ImVector3f
|
||||||
) {
|
) {
|
||||||
def create =
|
def behavior =
|
||||||
Behaviors.setup[Command] { ctx =>
|
Behaviors.setup[Command] { ctx =>
|
||||||
val npcMovementActor = ctx.spawn(
|
val npcMovementActor = ctx.spawn(
|
||||||
(npcMovementActorBehavior),
|
(npcMovementActorBehavior),
|
||||||
@ -58,7 +58,7 @@ object NpcActorSupervisor {
|
|||||||
final case class State(
|
final case class State(
|
||||||
)
|
)
|
||||||
final case class Children(
|
final case class Children(
|
||||||
npcMovementActor: ActorRef[NpcMovementActor2.Command]
|
npcMovementActor: ActorRef[NpcMovementActor.Command]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
class NpcActorSupervisor(
|
class NpcActorSupervisor(
|
||||||
@ -73,21 +73,21 @@ class NpcActorSupervisor(
|
|||||||
GenericTimerActor
|
GenericTimerActor
|
||||||
.Props(
|
.Props(
|
||||||
children.npcMovementActor,
|
children.npcMovementActor,
|
||||||
NpcMovementActor2.MovementTick,
|
NpcMovementActor.MovementTick,
|
||||||
100.millis
|
100.millis
|
||||||
)
|
)
|
||||||
.create,
|
.behavior,
|
||||||
s"npc-John-NpcActorTimer"
|
s"npc-John-NpcActorTimer"
|
||||||
)
|
)
|
||||||
|
|
||||||
def idle(state: State): Behavior[NpcActorSupervisor.Command] =
|
def idle(state: State): Behavior[NpcActorSupervisor.Command] =
|
||||||
Behaviors.setup { _ =>
|
Behaviors.setup { _ =>
|
||||||
ctx.log.info("Inside Idle State")
|
ctx.log.debug("Inside Idle State")
|
||||||
Behaviors.receiveMessage[Command] {
|
Behaviors.receiveMessage[Command] {
|
||||||
case m @ Move(pos) =>
|
case m @ Move(pos) =>
|
||||||
ctx.ask(
|
ctx.ask(
|
||||||
children.npcMovementActor,
|
children.npcMovementActor,
|
||||||
NpcMovementActor2.MoveTo(pos, _)
|
NpcMovementActor.MoveTo(pos, _)
|
||||||
) {
|
) {
|
||||||
case Success(signal) => InternalMove(m, signal)
|
case Success(signal) => InternalMove(m, signal)
|
||||||
case Failure(exception) => LogError(exception)
|
case Failure(exception) => LogError(exception)
|
||||||
@ -106,7 +106,7 @@ class NpcActorSupervisor(
|
|||||||
def moving(
|
def moving(
|
||||||
state: State,
|
state: State,
|
||||||
targetPos: ImVector3f,
|
targetPos: ImVector3f,
|
||||||
signal: CancelableFuture[NpcMovementActor2.DoneMoving.type]
|
signal: CancelableFuture[NpcMovementActor.DoneMoving.type]
|
||||||
): Behavior[NpcActorSupervisor.Command] =
|
): Behavior[NpcActorSupervisor.Command] =
|
||||||
Behaviors.setup { _ =>
|
Behaviors.setup { _ =>
|
||||||
movementTimer ! GenericTimerActor.Start
|
movementTimer ! GenericTimerActor.Start
|
||||||
@ -125,11 +125,11 @@ class NpcActorSupervisor(
|
|||||||
Behaviors.same
|
Behaviors.same
|
||||||
case m @ Move(pos) =>
|
case m @ Move(pos) =>
|
||||||
movementTimer ! GenericTimerActor.Stop
|
movementTimer ! GenericTimerActor.Stop
|
||||||
children.npcMovementActor ! NpcMovementActor2.StopMoving
|
children.npcMovementActor ! NpcMovementActor.StopMoving
|
||||||
signal.cancel()
|
signal.cancel()
|
||||||
ctx.ask(
|
ctx.ask(
|
||||||
children.npcMovementActor,
|
children.npcMovementActor,
|
||||||
NpcMovementActor2.MoveTo(pos, _)
|
NpcMovementActor.MoveTo(pos, _)
|
||||||
) {
|
) {
|
||||||
case Success(signal) => InternalMove(m, signal)
|
case Success(signal) => InternalMove(m, signal)
|
||||||
case Failure(exception) => LogError(exception)
|
case Failure(exception) => LogError(exception)
|
||||||
@ -148,7 +148,7 @@ class NpcActorSupervisor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object NpcMovementActor2 {
|
object NpcMovementActor {
|
||||||
|
|
||||||
case object DoneMoving
|
case object DoneMoving
|
||||||
|
|
||||||
@ -167,25 +167,25 @@ object NpcMovementActor2 {
|
|||||||
// val tickEventBus: GameEventBus[TickEvent],
|
// val tickEventBus: GameEventBus[TickEvent],
|
||||||
val movable: T
|
val movable: T
|
||||||
) {
|
) {
|
||||||
def create =
|
def behavior =
|
||||||
Behaviors.setup[Command] { ctx =>
|
Behaviors.setup[Command] { ctx =>
|
||||||
new NpcMovementActor2(ctx, this).receive(State())
|
new NpcMovementActor(ctx, this).receive(State())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final case class State()
|
final case class State()
|
||||||
}
|
}
|
||||||
class NpcMovementActor2[T](
|
class NpcMovementActor[T](
|
||||||
ctx: ActorContext[NpcMovementActor2.Command],
|
ctx: ActorContext[NpcMovementActor.Command],
|
||||||
props: NpcMovementActor2.Props[T]
|
props: NpcMovementActor.Props[T]
|
||||||
)(implicit cm: CanMove[T]) {
|
)(implicit cm: CanMove[T]) {
|
||||||
import NpcMovementActor2._
|
import NpcMovementActor._
|
||||||
|
|
||||||
def location = cm.location(props.movable)
|
def location = cm.location(props.movable)
|
||||||
|
|
||||||
def receive(
|
def receive(
|
||||||
state: State
|
state: State
|
||||||
): Behavior[NpcMovementActor2.Command] =
|
): Behavior[NpcMovementActor.Command] =
|
||||||
Behaviors.receiveMessagePartial {
|
Behaviors.receiveMessagePartial {
|
||||||
case AskPosition(replyTo) =>
|
case AskPosition(replyTo) =>
|
||||||
replyTo ! location
|
replyTo ! location
|
||||||
@ -211,7 +211,7 @@ class NpcMovementActor2[T](
|
|||||||
reachDestination: CancelablePromise[DoneMoving.type],
|
reachDestination: CancelablePromise[DoneMoving.type],
|
||||||
targetPos: ImVector3f,
|
targetPos: ImVector3f,
|
||||||
state: State
|
state: State
|
||||||
): Behavior[NpcMovementActor2.Command] =
|
): Behavior[NpcMovementActor.Command] =
|
||||||
Behaviors.receiveMessagePartial {
|
Behaviors.receiveMessagePartial {
|
||||||
case StopMoving =>
|
case StopMoving =>
|
||||||
ctx.log.debug(
|
ctx.log.debug(
|
||||||
@ -234,7 +234,7 @@ class NpcMovementActor2[T](
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object NpcMovementActor {
|
object NpcMovementActorNotUsed {
|
||||||
sealed trait Command
|
sealed trait Command
|
||||||
final case class Props(
|
final case class Props(
|
||||||
imMovementActorBehavior: Behavior[ImMovementActor.Command],
|
imMovementActorBehavior: Behavior[ImMovementActor.Command],
|
||||||
@ -246,7 +246,7 @@ object NpcMovementActor {
|
|||||||
tickEventBus: GameEventBus[TickEvent]
|
tickEventBus: GameEventBus[TickEvent]
|
||||||
) {
|
) {
|
||||||
|
|
||||||
def create: Behavior[Command] =
|
def behavior: Behavior[Command] =
|
||||||
Behaviors.setup { ctx =>
|
Behaviors.setup { ctx =>
|
||||||
val movementActor = ctx.spawn(
|
val movementActor = ctx.spawn(
|
||||||
Behaviors
|
Behaviors
|
||||||
|
@ -15,8 +15,7 @@ import org.slf4j.event.Level
|
|||||||
import wow.doge.mygame.game.subsystems.movement.CanMove
|
import wow.doge.mygame.game.subsystems.movement.CanMove
|
||||||
import wow.doge.mygame.subsystems.events.EventBus
|
import wow.doge.mygame.subsystems.events.EventBus
|
||||||
import wow.doge.mygame.subsystems.events.EventsModule.GameEventBus
|
import wow.doge.mygame.subsystems.events.EventsModule.GameEventBus
|
||||||
import wow.doge.mygame.subsystems.events.PlayerCameraEvent
|
import wow.doge.mygame.subsystems.events.PlayerEvent
|
||||||
import wow.doge.mygame.subsystems.events.PlayerMovementEvent
|
|
||||||
import wow.doge.mygame.subsystems.events.TickEvent
|
import wow.doge.mygame.subsystems.events.TickEvent
|
||||||
import wow.doge.mygame.subsystems.events.TickEvent.RenderTick
|
import wow.doge.mygame.subsystems.events.TickEvent.RenderTick
|
||||||
import wow.doge.mygame.subsystems.movement.ImMovementActor
|
import wow.doge.mygame.subsystems.movement.ImMovementActor
|
||||||
@ -24,15 +23,12 @@ import wow.doge.mygame.subsystems.movement.ImMovementActor
|
|||||||
object PlayerActorSupervisor {
|
object PlayerActorSupervisor {
|
||||||
sealed trait Command
|
sealed trait Command
|
||||||
final case class Props(
|
final case class Props(
|
||||||
playerMovementEventBus: ActorRef[
|
playerEventBus: GameEventBus[PlayerEvent],
|
||||||
EventBus.Command[PlayerMovementEvent]
|
|
||||||
],
|
|
||||||
playerCameraEventBus: ActorRef[EventBus.Command[PlayerCameraEvent]],
|
|
||||||
tickEventBus: GameEventBus[TickEvent],
|
tickEventBus: GameEventBus[TickEvent],
|
||||||
imMovementActorBehavior: Behavior[ImMovementActor.Command],
|
imMovementActorBehavior: Behavior[ImMovementActor.Command],
|
||||||
playerCameraActorBehavior: Behavior[PlayerCameraActor.Command]
|
playerCameraActorBehavior: Behavior[PlayerCameraActor.Command]
|
||||||
) {
|
) {
|
||||||
def create[T: CanMove](movable: T) =
|
def behavior[T: CanMove](movable: T) =
|
||||||
Behaviors.logMessages(
|
Behaviors.logMessages(
|
||||||
LogOptions()
|
LogOptions()
|
||||||
.withLevel(Level.TRACE)
|
.withLevel(Level.TRACE)
|
||||||
@ -64,15 +60,15 @@ object PlayerActorSupervisor {
|
|||||||
.Props(
|
.Props(
|
||||||
movementActor,
|
movementActor,
|
||||||
playerCameraActor,
|
playerCameraActor,
|
||||||
playerMovementEventBus,
|
playerEventBus,
|
||||||
tickEventBus
|
tickEventBus
|
||||||
)
|
)
|
||||||
.create,
|
.behavior,
|
||||||
"playerMovementAcor"
|
"playerMovementAcor"
|
||||||
)
|
)
|
||||||
|
|
||||||
//init actors
|
//init actors
|
||||||
playerCameraEventBus ! EventBus.Subscribe(playerCameraEl)
|
playerEventBus ! EventBus.Subscribe(playerCameraEl)
|
||||||
|
|
||||||
new PlayerActorSupervisor(
|
new PlayerActorSupervisor(
|
||||||
ctx,
|
ctx,
|
||||||
@ -107,13 +103,11 @@ object PlayerMovementActor {
|
|||||||
final case class Props(
|
final case class Props(
|
||||||
movementActor: ActorRef[ImMovementActor.Command],
|
movementActor: ActorRef[ImMovementActor.Command],
|
||||||
playerCameraActor: ActorRef[PlayerCameraActor.Command],
|
playerCameraActor: ActorRef[PlayerCameraActor.Command],
|
||||||
playerMovementEventBus: ActorRef[
|
playerEventBus: GameEventBus[PlayerEvent],
|
||||||
EventBus.Command[PlayerMovementEvent]
|
|
||||||
],
|
|
||||||
tickEventBus: GameEventBus[TickEvent]
|
tickEventBus: GameEventBus[TickEvent]
|
||||||
) {
|
) {
|
||||||
|
|
||||||
def create: Behavior[Command] =
|
def behavior: Behavior[Command] =
|
||||||
Behaviors.setup { ctx =>
|
Behaviors.setup { ctx =>
|
||||||
val playerMovementEl = ctx.spawn(
|
val playerMovementEl = ctx.spawn(
|
||||||
Behaviors
|
Behaviors
|
||||||
@ -131,7 +125,7 @@ object PlayerMovementActor {
|
|||||||
val renderTickEl =
|
val renderTickEl =
|
||||||
ctx.spawn(renderTickElBehavior, "playerMovementTickListener")
|
ctx.spawn(renderTickElBehavior, "playerMovementTickListener")
|
||||||
|
|
||||||
playerMovementEventBus ! EventBus.Subscribe(playerMovementEl)
|
playerEventBus ! EventBus.Subscribe(playerMovementEl)
|
||||||
tickEventBus ! EventBus.Subscribe(renderTickEl)
|
tickEventBus ! EventBus.Subscribe(renderTickEl)
|
||||||
Behaviors.receiveMessage { msg => Behaviors.same }
|
Behaviors.receiveMessage { msg => Behaviors.same }
|
||||||
}
|
}
|
||||||
@ -150,7 +144,7 @@ object GenericTimerActor {
|
|||||||
messageToSend: T,
|
messageToSend: T,
|
||||||
timeInterval: FiniteDuration
|
timeInterval: FiniteDuration
|
||||||
) {
|
) {
|
||||||
val create = Behaviors.withTimers[Command] { timers =>
|
val behavior = Behaviors.withTimers[Command] { timers =>
|
||||||
new GenericTimerActor(timers, TimerKey(Random.nextLong()), this).idle
|
new GenericTimerActor(timers, TimerKey(Random.nextLong()), this).idle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ object PlayerCameraActor {
|
|||||||
val enqueueR: Function1[() => Unit, Unit],
|
val enqueueR: Function1[() => Unit, Unit],
|
||||||
val getPlayerLocation: Function0[Vector3f]
|
val getPlayerLocation: Function0[Vector3f]
|
||||||
) {
|
) {
|
||||||
def create =
|
def behavior =
|
||||||
Behaviors.logMessages(
|
Behaviors.logMessages(
|
||||||
LogOptions()
|
LogOptions()
|
||||||
.withLevel(Level.TRACE)
|
.withLevel(Level.TRACE)
|
||||||
|
@ -24,10 +24,8 @@ import wow.doge.mygame.game.SimpleAppExt
|
|||||||
import wow.doge.mygame.implicits._
|
import wow.doge.mygame.implicits._
|
||||||
import wow.doge.mygame.math.ImVector3f
|
import wow.doge.mygame.math.ImVector3f
|
||||||
import wow.doge.mygame.state.MyMaterial
|
import wow.doge.mygame.state.MyMaterial
|
||||||
import wow.doge.mygame.subsystems.events.EventBus
|
|
||||||
import wow.doge.mygame.subsystems.events.EventsModule.GameEventBus
|
import wow.doge.mygame.subsystems.events.EventsModule.GameEventBus
|
||||||
import wow.doge.mygame.subsystems.events.PlayerCameraEvent
|
import wow.doge.mygame.subsystems.events.PlayerEvent
|
||||||
import wow.doge.mygame.subsystems.events.PlayerMovementEvent
|
|
||||||
import wow.doge.mygame.subsystems.events.TickEvent
|
import wow.doge.mygame.subsystems.events.TickEvent
|
||||||
import wow.doge.mygame.subsystems.movement.ImMovementActor
|
import wow.doge.mygame.subsystems.movement.ImMovementActor
|
||||||
import wow.doge.mygame.utils.AkkaUtils
|
import wow.doge.mygame.utils.AkkaUtils
|
||||||
@ -50,10 +48,7 @@ object PlayerController {
|
|||||||
physicsSpace: PhysicsSpace,
|
physicsSpace: PhysicsSpace,
|
||||||
initialPlayerPos: ImVector3f = ImVector3f.ZERO,
|
initialPlayerPos: ImVector3f = ImVector3f.ZERO,
|
||||||
spawnProtocol: ActorRef[SpawnProtocol.Command],
|
spawnProtocol: ActorRef[SpawnProtocol.Command],
|
||||||
playerMovementEventBus: ActorRef[
|
playerEventBus: GameEventBus[PlayerEvent],
|
||||||
EventBus.Command[PlayerMovementEvent]
|
|
||||||
],
|
|
||||||
playerCameraEventBus: ActorRef[EventBus.Command[PlayerCameraEvent]],
|
|
||||||
playerPhysicsControl: BetterCharacterControl,
|
playerPhysicsControl: BetterCharacterControl,
|
||||||
appScheduler: monix.execution.Scheduler,
|
appScheduler: monix.execution.Scheduler,
|
||||||
playerNode: Node @@ PlayerControllerTags.PlayerTag,
|
playerNode: Node @@ PlayerControllerTags.PlayerTag,
|
||||||
@ -68,22 +63,22 @@ object PlayerController {
|
|||||||
spawnProtocol,
|
spawnProtocol,
|
||||||
"playerActorSupervisor",
|
"playerActorSupervisor",
|
||||||
new PlayerActorSupervisor.Props(
|
new PlayerActorSupervisor.Props(
|
||||||
playerMovementEventBus,
|
playerEventBus,
|
||||||
playerCameraEventBus,
|
// playerCameraEventBus,
|
||||||
tickEventBus,
|
tickEventBus,
|
||||||
new ImMovementActor.Props(
|
new ImMovementActor.Props(
|
||||||
enqueueR,
|
enqueueR,
|
||||||
playerPhysicsControl,
|
playerPhysicsControl,
|
||||||
camera
|
camera
|
||||||
).create,
|
).behavior,
|
||||||
// wireWith(PlayerCameraEventListener.apply _)
|
// wireWith(PlayerCameraEventListener.apply _)
|
||||||
// PlayerCameraEventListener()
|
// PlayerCameraEventListener()
|
||||||
new PlayerCameraActor.Props(
|
new PlayerCameraActor.Props(
|
||||||
cameraPivotNode,
|
cameraPivotNode,
|
||||||
enqueueR,
|
enqueueR,
|
||||||
playerNode.getWorldTranslation _
|
playerNode.getWorldTranslation _
|
||||||
).create
|
).behavior
|
||||||
).create(playerPhysicsControl)
|
).behavior(playerPhysicsControl)
|
||||||
)
|
)
|
||||||
_ <- Task(rootNode += playerNode)
|
_ <- Task(rootNode += playerNode)
|
||||||
_ <- IO {
|
_ <- IO {
|
||||||
|
@ -15,6 +15,7 @@ import wow.doge.mygame.implicits._
|
|||||||
import wow.doge.mygame.subsystems.events.EventBus
|
import wow.doge.mygame.subsystems.events.EventBus
|
||||||
import wow.doge.mygame.subsystems.events.EventsModule.GameEventBus
|
import wow.doge.mygame.subsystems.events.EventsModule.GameEventBus
|
||||||
import wow.doge.mygame.subsystems.events.PlayerCameraEvent
|
import wow.doge.mygame.subsystems.events.PlayerCameraEvent
|
||||||
|
import wow.doge.mygame.subsystems.events.PlayerEvent
|
||||||
import wow.doge.mygame.subsystems.events.PlayerMovementEvent
|
import wow.doge.mygame.subsystems.events.PlayerMovementEvent
|
||||||
import wow.doge.mygame.utils.IOUtils._
|
import wow.doge.mygame.utils.IOUtils._
|
||||||
|
|
||||||
@ -22,8 +23,8 @@ object GameInputHandler {
|
|||||||
|
|
||||||
final class Props(
|
final class Props(
|
||||||
inputManager: InputManager,
|
inputManager: InputManager,
|
||||||
playerMovementEventBus: GameEventBus[PlayerMovementEvent],
|
playerEventBus: GameEventBus[PlayerEvent]
|
||||||
playerCameraEventBus: GameEventBus[PlayerCameraEvent]
|
// playerCameraEventBus: GameEventBus[PlayerCameraEvent]
|
||||||
// tickEventBus: GameEventBus[TickEvent]
|
// tickEventBus: GameEventBus[TickEvent]
|
||||||
) {
|
) {
|
||||||
def begin =
|
def begin =
|
||||||
@ -34,19 +35,19 @@ object GameInputHandler {
|
|||||||
_ <- toIO(
|
_ <- toIO(
|
||||||
generateMovementInputEvents(
|
generateMovementInputEvents(
|
||||||
inputManager,
|
inputManager,
|
||||||
playerMovementEventBus
|
playerEventBus
|
||||||
).completedL.startAndForget
|
).completedL.startAndForget
|
||||||
)
|
)
|
||||||
_ <- toIO(
|
_ <- toIO(
|
||||||
generateAnalogMovementEvents(
|
generateAnalogMovementEvents(
|
||||||
inputManager,
|
inputManager,
|
||||||
playerMovementEventBus
|
playerEventBus
|
||||||
).completedL.startAndForget
|
).completedL.startAndForget
|
||||||
)
|
)
|
||||||
_ <- toIO(
|
_ <- toIO(
|
||||||
generateCameraEvents(
|
generateCameraEvents(
|
||||||
inputManager,
|
inputManager,
|
||||||
playerCameraEventBus
|
playerEventBus
|
||||||
).completedL.startAndForget
|
).completedL.startAndForget
|
||||||
)
|
)
|
||||||
_ <- toIO(
|
_ <- toIO(
|
||||||
@ -130,9 +131,7 @@ object GameInputHandler {
|
|||||||
|
|
||||||
def generateMovementInputEvents(
|
def generateMovementInputEvents(
|
||||||
inputManager: InputManager,
|
inputManager: InputManager,
|
||||||
playerMovementEventBus: ActorRef[
|
playerEventBus: GameEventBus[PlayerEvent]
|
||||||
EventBus.Command[PlayerMovementEvent]
|
|
||||||
]
|
|
||||||
) = {
|
) = {
|
||||||
val name = "playerMovementInputEventsGenerator"
|
val name = "playerMovementInputEventsGenerator"
|
||||||
inputManager
|
inputManager
|
||||||
@ -142,28 +141,28 @@ object GameInputHandler {
|
|||||||
action.binding match {
|
action.binding match {
|
||||||
case PlayerMovementInput.WalkLeft =>
|
case PlayerMovementInput.WalkLeft =>
|
||||||
me.Task(
|
me.Task(
|
||||||
playerMovementEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerMovementEvent.PlayerMovedLeft(pressed = action.value),
|
PlayerMovementEvent.PlayerMovedLeft(pressed = action.value),
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
case PlayerMovementInput.WalkRight =>
|
case PlayerMovementInput.WalkRight =>
|
||||||
me.Task(
|
me.Task(
|
||||||
playerMovementEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerMovementEvent.PlayerMovedRight(pressed = action.value),
|
PlayerMovementEvent.PlayerMovedRight(pressed = action.value),
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
case PlayerMovementInput.WalkForward =>
|
case PlayerMovementInput.WalkForward =>
|
||||||
me.Task(
|
me.Task(
|
||||||
playerMovementEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerMovementEvent.PlayerMovedForward(pressed = action.value),
|
PlayerMovementEvent.PlayerMovedForward(pressed = action.value),
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
case PlayerMovementInput.WalkBackward =>
|
case PlayerMovementInput.WalkBackward =>
|
||||||
me.Task(
|
me.Task(
|
||||||
playerMovementEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerMovementEvent.PlayerMovedBackward(pressed = action.value),
|
PlayerMovementEvent.PlayerMovedBackward(pressed = action.value),
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
@ -171,7 +170,7 @@ object GameInputHandler {
|
|||||||
case PlayerMovementInput.Jump =>
|
case PlayerMovementInput.Jump =>
|
||||||
if (action.value) {
|
if (action.value) {
|
||||||
me.Task(
|
me.Task(
|
||||||
playerMovementEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerMovementEvent.PlayerJumped,
|
PlayerMovementEvent.PlayerJumped,
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
@ -183,9 +182,7 @@ object GameInputHandler {
|
|||||||
|
|
||||||
def generateAnalogMovementEvents(
|
def generateAnalogMovementEvents(
|
||||||
inputManager: InputManager,
|
inputManager: InputManager,
|
||||||
playerMovementEventBus: ActorRef[
|
playerEventBus: GameEventBus[PlayerEvent]
|
||||||
EventBus.Command[PlayerMovementEvent]
|
|
||||||
]
|
|
||||||
) = {
|
) = {
|
||||||
// val name = "analogMovementEventsGenerator"
|
// val name = "analogMovementEventsGenerator"
|
||||||
inputManager
|
inputManager
|
||||||
@ -213,7 +210,7 @@ object GameInputHandler {
|
|||||||
|
|
||||||
def generateCameraEvents(
|
def generateCameraEvents(
|
||||||
inputManager: InputManager,
|
inputManager: InputManager,
|
||||||
playerCameraEventBus: ActorRef[EventBus.Command[PlayerCameraEvent]]
|
playerEventBus: ActorRef[EventBus.Command[PlayerEvent]]
|
||||||
) = {
|
) = {
|
||||||
val name = "cameraMovementEventsGenerator"
|
val name = "cameraMovementEventsGenerator"
|
||||||
inputManager
|
inputManager
|
||||||
@ -223,28 +220,28 @@ object GameInputHandler {
|
|||||||
analogEvent.binding match {
|
analogEvent.binding match {
|
||||||
case PlayerCameraInput.CameraRotateLeft =>
|
case PlayerCameraInput.CameraRotateLeft =>
|
||||||
me.Task(
|
me.Task(
|
||||||
playerCameraEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerCameraEvent.CameraLeft,
|
PlayerCameraEvent.CameraLeft,
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
case PlayerCameraInput.CameraRotateRight =>
|
case PlayerCameraInput.CameraRotateRight =>
|
||||||
me.Task(
|
me.Task(
|
||||||
playerCameraEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerCameraEvent.CameraRight,
|
PlayerCameraEvent.CameraRight,
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
case PlayerCameraInput.CameraRotateUp =>
|
case PlayerCameraInput.CameraRotateUp =>
|
||||||
me.Task(
|
me.Task(
|
||||||
playerCameraEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerCameraEvent.CameraMovedUp,
|
PlayerCameraEvent.CameraMovedUp,
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
case PlayerCameraInput.CameraRotateDown =>
|
case PlayerCameraInput.CameraRotateDown =>
|
||||||
me.Task(
|
me.Task(
|
||||||
playerCameraEventBus ! EventBus.Publish(
|
playerEventBus ! EventBus.Publish(
|
||||||
PlayerCameraEvent.CameraMovedDown,
|
PlayerCameraEvent.CameraMovedDown,
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
|
@ -56,7 +56,7 @@ object CanMove {
|
|||||||
inst.setWalkDirection(Vector3f.ZERO)
|
inst.setWalkDirection(Vector3f.ZERO)
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit val implCanMoveForGeom = new CanMove[Spatial] with LazyLogging {
|
implicit val implCanMoveForSpatial = new CanMove[Spatial] with LazyLogging {
|
||||||
override def move(
|
override def move(
|
||||||
inst: Spatial,
|
inst: Spatial,
|
||||||
direction: ImVector3f,
|
direction: ImVector3f,
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
package wow.doge.mygame.game.subsystems.movement
|
||||||
|
|
||||||
|
import com.jme3.bullet.control.BetterCharacterControl
|
||||||
|
import com.jme3.math.FastMath
|
||||||
|
import com.jme3.math.Quaternion
|
||||||
|
import com.jme3.math.Vector3f
|
||||||
|
import monix.eval.Coeval
|
||||||
|
import wow.doge.mygame.implicits._
|
||||||
|
import wow.doge.mygame.math.ImVector3f
|
||||||
|
import wow.doge.mygame.subsystems.movement.RotateDir
|
||||||
|
|
||||||
|
// experiment to see if it would be useful to use an effect wrapper for a typeclass like this
|
||||||
|
trait CanMove2[-A, F[_]] {
|
||||||
|
// def getDirection(cam: Camera, cardinalDir: CardinalDirection): ImVector3f
|
||||||
|
def move(inst: A, direction: ImVector3f, speedFactor: Float = 20f): F[Unit]
|
||||||
|
def location(inst: A): F[ImVector3f]
|
||||||
|
def jump(inst: A): F[Unit]
|
||||||
|
def stop(inst: A): F[Unit]
|
||||||
|
def rotate(inst: A, rotateDir: RotateDir): F[Unit]
|
||||||
|
}
|
||||||
|
|
||||||
|
object CanMove2 {
|
||||||
|
implicit val implCanMoveForBetterCharacterControl =
|
||||||
|
new CanMove2[BetterCharacterControl, Coeval] {
|
||||||
|
override def move(
|
||||||
|
inst: BetterCharacterControl,
|
||||||
|
direction: ImVector3f,
|
||||||
|
speedFactor: Float = 20f
|
||||||
|
): Coeval[Unit] =
|
||||||
|
Coeval {
|
||||||
|
val dir = direction.mutable.normalizeLocal()
|
||||||
|
inst.setViewDirection(dir.negate())
|
||||||
|
inst.setWalkDirection(dir.mult(speedFactor))
|
||||||
|
}
|
||||||
|
override def location(inst: BetterCharacterControl) =
|
||||||
|
Coeval(inst.getSpatial().getLocalTranslation().immutable)
|
||||||
|
override def jump(inst: BetterCharacterControl): Coeval[Unit] =
|
||||||
|
Coeval(inst.jump())
|
||||||
|
override def rotate(
|
||||||
|
inst: BetterCharacterControl,
|
||||||
|
rotateDir: RotateDir
|
||||||
|
): Coeval[Unit] =
|
||||||
|
Coeval {
|
||||||
|
val q =
|
||||||
|
rotateDir match {
|
||||||
|
case RotateDir.Left =>
|
||||||
|
new Quaternion()
|
||||||
|
.fromAngleNormalAxis(5 * FastMath.DEG_TO_RAD, Vector3f.UNIT_Y)
|
||||||
|
case RotateDir.Right =>
|
||||||
|
new Quaternion()
|
||||||
|
.fromAngleAxis(-5 * FastMath.DEG_TO_RAD, Vector3f.UNIT_Y)
|
||||||
|
}
|
||||||
|
|
||||||
|
val tmp = new Vector3f()
|
||||||
|
inst.getViewDirection(tmp)
|
||||||
|
inst.setViewDirection(q.mult(tmp))
|
||||||
|
}
|
||||||
|
override def stop(inst: BetterCharacterControl) =
|
||||||
|
Coeval(inst.setWalkDirection(Vector3f.ZERO))
|
||||||
|
}
|
||||||
|
}
|
@ -39,7 +39,7 @@ object ImMovementActor {
|
|||||||
// ]
|
// ]
|
||||||
val camera: Camera
|
val camera: Camera
|
||||||
) {
|
) {
|
||||||
def create: Behavior[Command] =
|
def behavior: Behavior[Command] =
|
||||||
Behaviors.setup(ctx => new ImMovementActor(ctx, this).receive(State()))
|
Behaviors.setup(ctx => new ImMovementActor(ctx, this).receive(State()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ class EventsModule(spawnProtocol: ActorSystem[SpawnProtocol.Command]) {
|
|||||||
|
|
||||||
lazy val eventBusLogger = SLogger[EventBus[_]]
|
lazy val eventBusLogger = SLogger[EventBus[_]]
|
||||||
|
|
||||||
lazy val playerMovementEventBusTask =
|
lazy val playerEventBusTask =
|
||||||
createEventBus[PlayerMovementEvent]("movementEventBus")
|
createEventBus[PlayerEvent]("playerEventBus")
|
||||||
|
|
||||||
lazy val playerCameraEventBusTask =
|
// lazy val playerCameraEventBusTask =
|
||||||
createEventBus[PlayerCameraEvent]("playerCameraEventBus", Level.DEBUG)
|
// createEventBus[PlayerCameraEvent]("playerCameraEventBus", Level.DEBUG)
|
||||||
|
|
||||||
lazy val tickEventBusTask =
|
lazy val tickEventBusTask =
|
||||||
createEventBus[TickEvent]("tickEventBus", Level.TRACE)
|
createEventBus[TickEvent]("tickEventBus", Level.TRACE)
|
||||||
|
@ -19,6 +19,13 @@ import groovy.util.GroovyScriptEngine
|
|||||||
import org.slf4j.event.Level
|
import org.slf4j.event.Level
|
||||||
|
|
||||||
object ScriptActor {
|
object ScriptActor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aka script representation
|
||||||
|
*/
|
||||||
|
sealed trait ScriptTag
|
||||||
|
type ScriptObject = Any @@ ScriptTag
|
||||||
|
|
||||||
trait Kotlin
|
trait Kotlin
|
||||||
type KotlinScriptEngine = ScriptEngine @@ Kotlin
|
type KotlinScriptEngine = ScriptEngine @@ Kotlin
|
||||||
|
|
||||||
@ -26,7 +33,7 @@ object ScriptActor {
|
|||||||
sealed trait Command
|
sealed trait Command
|
||||||
final case class CompileAny(
|
final case class CompileAny(
|
||||||
path: os.Path,
|
path: os.Path,
|
||||||
result: ActorRef[Either[Error, Any]]
|
result: ActorRef[Either[Error, ScriptObject]]
|
||||||
) extends Command
|
) extends Command
|
||||||
|
|
||||||
final case class CompileAll(
|
final case class CompileAll(
|
||||||
@ -145,15 +152,21 @@ class ScriptActor(
|
|||||||
Behaviors.same
|
Behaviors.same
|
||||||
}
|
}
|
||||||
|
|
||||||
def getScript(path: os.Path): Either[Error, Any] =
|
def getScript(path: os.Path): Either[Error, ScriptObject] =
|
||||||
determineScriptType(path) match {
|
determineScriptType(path) match {
|
||||||
case Right(ScalaType) =>
|
case Right(ScalaType) =>
|
||||||
runScala(path, scalaRunner).flatMap(ensureReturnedObjectNotNull)
|
runScala(path, scalaRunner)
|
||||||
|
.flatMap(ensureReturnedObjectNotNull)
|
||||||
|
.map(_.taggedWith[ScriptTag])
|
||||||
case Right(KotlinType) =>
|
case Right(KotlinType) =>
|
||||||
runKotlin(path, kotlinRunner).flatMap(ensureReturnedObjectNotNull)
|
runKotlin(path, kotlinRunner)
|
||||||
|
.flatMap(ensureReturnedObjectNotNull)
|
||||||
|
.map(_.taggedWith[ScriptTag])
|
||||||
case Right(GroovyType) =>
|
case Right(GroovyType) =>
|
||||||
runGroovy(path, groovyRunner).flatMap(ensureReturnedObjectNotNull)
|
runGroovy(path, groovyRunner)
|
||||||
case l @ Left(err) => l
|
.flatMap(ensureReturnedObjectNotNull)
|
||||||
|
.map(_.taggedWith[ScriptTag])
|
||||||
|
case l @ Left(err) => l.map(_.taggedWith[ScriptTag])
|
||||||
}
|
}
|
||||||
|
|
||||||
type LOL = Map[os.Path, Either[wow.doge.mygame.state.ScriptActor.Error, Any]]
|
type LOL = Map[os.Path, Either[wow.doge.mygame.state.ScriptActor.Error, Any]]
|
||||||
|
@ -15,13 +15,11 @@ import akka.util.Timeout
|
|||||||
import com.typesafe.scalalogging.Logger
|
import com.typesafe.scalalogging.Logger
|
||||||
import org.slf4j.event.Level
|
import org.slf4j.event.Level
|
||||||
import wow.doge.mygame.state.ScriptActor
|
import wow.doge.mygame.state.ScriptActor
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import ScriptActor.ScriptObject
|
||||||
|
|
||||||
object ScriptCachingActor {
|
object ScriptCachingActor {
|
||||||
|
|
||||||
/**
|
|
||||||
* aka script representation
|
|
||||||
*/
|
|
||||||
type ScriptObject = Any
|
|
||||||
type ScriptsMap = Map[os.Path, ScriptObject]
|
type ScriptsMap = Map[os.Path, ScriptObject]
|
||||||
type ScriptResult = Either[ScriptActor.Error, ScriptObject]
|
type ScriptResult = Either[ScriptActor.Error, ScriptObject]
|
||||||
|
|
||||||
@ -162,7 +160,6 @@ class ScriptCachingActor(
|
|||||||
// Behaviors.same
|
// Behaviors.same
|
||||||
|
|
||||||
case DelegateToChild(scriptActor, scriptPath, requester) =>
|
case DelegateToChild(scriptActor, scriptPath, requester) =>
|
||||||
import scala.concurrent.duration._
|
|
||||||
implicit val timeout = Timeout(15.seconds)
|
implicit val timeout = Timeout(15.seconds)
|
||||||
// child ! ScriptActor.CompileAny(scriptPath, requester)
|
// child ! ScriptActor.CompileAny(scriptPath, requester)
|
||||||
askChildForScriptCompilation(
|
askChildForScriptCompilation(
|
||||||
|
Loading…
Reference in New Issue
Block a user