mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 08:39:17 +00:00
Add unit tests for areas plugin
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.event.impl.MobPositionUpdateEvent
|
||||
import org.apollo.game.plugins.area.actions
|
||||
|
||||
/**
|
||||
* Intercepts the [MobPositionUpdateEvent] and invokes area actions if necessary.
|
||||
*/
|
||||
on_event { MobPositionUpdateEvent::class }
|
||||
.where { mob is Player }
|
||||
.then {
|
||||
for ((area, action) in actions) {
|
||||
if (mob.position in area) {
|
||||
if (next in area) {
|
||||
action.inside(mob as Player, next)
|
||||
} else {
|
||||
action.exit(mob as Player, next)
|
||||
}
|
||||
} else if (next in area) {
|
||||
action.entrance(mob as Player, next)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user