mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-05 08:40:08 +00:00
Refactor asynchronous actions to avoid thread usage
Adds custom coroutines specifically for use within Actions. This implements all features of the previous system, however, does not rely on a separate executor to wake up continuations. Note: since Actions are still ran by an executor and a small chance of overlap exists the ActionCoroutine implementation uses atomic counters and references.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncAction
|
||||
import org.apollo.game.message.impl.ItemOptionMessage
|
||||
import org.apollo.game.model.Animation
|
||||
@@ -27,7 +28,7 @@ class ConsumeAction(val consumable: Consumable, player: Player, val slot: Int) :
|
||||
}
|
||||
}
|
||||
|
||||
suspend override fun executeActionAsync() {
|
||||
override fun action(): ActionBlock = {
|
||||
consumable.consume(mob, slot)
|
||||
mob.playAnimation(Animation(CONSUME_ANIMATION_ID))
|
||||
wait(consumable.delay)
|
||||
|
||||
Reference in New Issue
Block a user