mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-20 13:30:27 -07:00
Made interaction listener typed interaction type more backwards compatible
This commit is contained in:
parent
6ab68b008f
commit
b47141aa84
1 changed files with 11 additions and 10 deletions
|
|
@ -4,10 +4,20 @@ import api.ContentInterface
|
||||||
import core.game.node.Node
|
import core.game.node.Node
|
||||||
import core.game.node.entity.Entity
|
import core.game.node.entity.Entity
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
|
import core.game.node.item.Item
|
||||||
import core.game.world.map.Location
|
import core.game.world.map.Location
|
||||||
import rs09.game.system.SystemLogger
|
import rs09.game.system.SystemLogger
|
||||||
|
|
||||||
interface InteractionListener : ContentInterface{
|
interface InteractionListener : ContentInterface{
|
||||||
|
val ITEM
|
||||||
|
get() = IntType.ITEM
|
||||||
|
val GROUNDITEM
|
||||||
|
get() = IntType.GROUNDITEM
|
||||||
|
val NPC
|
||||||
|
get() = IntType.NPC
|
||||||
|
val SCENERY
|
||||||
|
get() = IntType.SCENERY
|
||||||
|
|
||||||
fun on(id: Int, type: IntType, vararg option: String, handler: (player: Player, node: Node) -> Boolean){
|
fun on(id: Int, type: IntType, vararg option: String, handler: (player: Player, node: Node) -> Boolean){
|
||||||
InteractionListeners.add(id,type.ordinal,option,handler)
|
InteractionListeners.add(id,type.ordinal,option,handler)
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +40,7 @@ interface InteractionListener : ContentInterface{
|
||||||
InteractionListeners.add(type.ordinal, with, handler)
|
InteractionListeners.add(type.ordinal, with, handler)
|
||||||
}
|
}
|
||||||
fun onUseWithPlayer(vararg used: Int, handler: (player: Player, used: Node, with: Node) -> Boolean) {
|
fun onUseWithPlayer(vararg used: Int, handler: (player: Player, used: Node, with: Node) -> Boolean) {
|
||||||
InteractionListeners.add(PLAYER, used, handler)
|
InteractionListeners.add(IntType.PLAYER.ordinal, used, handler)
|
||||||
}
|
}
|
||||||
// Note: wildcard listeners incur overhead on every use-with interaction, only use them as a space-time tradeoff when something
|
// Note: wildcard listeners incur overhead on every use-with interaction, only use them as a space-time tradeoff when something
|
||||||
// is actually supposed to have a response to every item used with it (e.g. imp boxes, certain quest npcs)
|
// is actually supposed to have a response to every item used with it (e.g. imp boxes, certain quest npcs)
|
||||||
|
|
@ -74,13 +84,4 @@ interface InteractionListener : ContentInterface{
|
||||||
}
|
}
|
||||||
|
|
||||||
fun defineListeners()
|
fun defineListeners()
|
||||||
|
|
||||||
companion object
|
|
||||||
{
|
|
||||||
val ITEM = 0
|
|
||||||
val SCENERY = 1
|
|
||||||
val NPC = 2
|
|
||||||
val GROUNDITEM = 3
|
|
||||||
val PLAYER = 4
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue