-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
engine/src/main/kotlin/org/redrune/engine/entity/event/player/PlayerEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.redrune.engine.entity.event.player | ||
|
||
import org.redrune.engine.entity.model.Player | ||
import org.redrune.engine.event.Event | ||
|
||
/** | ||
* @author Greg Hibberd <greg@greghibberd.com> | ||
* @since March 31, 2020 | ||
*/ | ||
abstract class PlayerEvent : Event() { | ||
abstract val player: Player | ||
} |
7 changes: 7 additions & 0 deletions
7
engine/src/main/kotlin/org/redrune/engine/entity/event/player/PlayerRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.redrune.engine.entity.event.player | ||
|
||
/** | ||
* @author Greg Hibberd <greg@greghibberd.com> | ||
* @since March 31, 2020 | ||
*/ | ||
typealias PlayerRequest = PlayerEvent |
13 changes: 13 additions & 0 deletions
13
engine/src/main/kotlin/org/redrune/engine/player/PlayerController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.redrune.engine.player | ||
|
||
import org.redrune.engine.entity.event.player.PlayerRequest | ||
|
||
/** | ||
* @author Greg Hibberd <greg@greghibberd.com> | ||
* @since March 31, 2020 | ||
*/ | ||
interface PlayerController { | ||
|
||
fun send(request: PlayerRequest) | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
engine/src/main/kotlin/org/redrune/engine/player/PlayerControls.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.redrune.engine.player | ||
|
||
import org.koin.dsl.module | ||
import org.redrune.engine.entity.event.player.PlayerRequest | ||
import org.redrune.engine.event.EventBus | ||
import org.redrune.utility.inject | ||
|
||
/** | ||
* @author Greg Hibberd <greg@greghibberd.com> | ||
* @since March 31, 2020 | ||
*/ | ||
class PlayerControls : PlayerController { | ||
|
||
private val bus: EventBus by inject() | ||
|
||
override fun send(request: PlayerRequest) { | ||
bus.emit(request) | ||
} | ||
|
||
} | ||
|
||
val controlModule = module { | ||
single { PlayerControls() as PlayerController } | ||
} |