Add support for asynchronous Mob actions

Adds asynchronous implementations of the Action and DistancedAction
classes, allowing plugins to make use of suspendable functions in Kotlin
instead of creating mini state machines to keep track of state.

The asynchronicity works by creating coroutine backed Channels for each
asynchronous action and having them listen on "pulse" events from the
action scheduler.  The action can then suspend execution until a pulse is
received or until some expensive operation has completed (i.e.,
pathfinding).

If an asynchronous action is still busy when a pulse arrives then the
number of missed pulses will be accumulated and sent to the action at
the next possible time.

The training dummy plugin has been updated to use asycnrhonous actions
as an example.
This commit is contained in:
Gary Tierney
2017-06-20 06:53:00 +01:00
parent 182de0330f
commit 97e85868ff
10 changed files with 156 additions and 187 deletions
+8
View File
@@ -24,6 +24,12 @@ sourceSets {
}
}
repositories {
maven {
url { 'https://dl.bintray.com/kotlin/kotlinx/' }
}
}
dependencies {
compile project(':cache')
compile project(':net')
@@ -32,6 +38,8 @@ dependencies {
compile group: 'io.github.lukehutch', name: 'fast-classpath-scanner', version: '2.0.21'
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jre8', version: "$kotlinVersion"
compile group: 'org.jetbrains.kotlin', name: 'kotlin-compiler-embeddable', version: "$kotlinVersion"
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-jdk8', version: '0.16'
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '0.16'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.8.0'
}