mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-17 12:00:17 -07:00
Redid shooting star option handling into listeners
This commit is contained in:
parent
3f204cf583
commit
71cea84609
4 changed files with 20 additions and 49 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
package rs09.game.content.global.worldevents.holiday
|
package rs09.game.content.global.worldevents.holiday.halloween
|
||||||
|
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.game.node.item.GroundItemManager
|
import core.game.node.item.GroundItemManager
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package rs09.game.content.global.worldevents.holiday
|
package rs09.game.content.global.worldevents.holiday.halloween
|
||||||
|
|
||||||
|
import core.game.content.dialogue.DialoguePlugin
|
||||||
|
import core.game.content.dialogue.FacialExpression
|
||||||
import core.game.node.entity.combat.ImpactHandler
|
import core.game.node.entity.combat.ImpactHandler
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.game.node.item.Item
|
import core.game.node.item.Item
|
||||||
import core.game.content.dialogue.DialoguePlugin
|
|
||||||
import core.game.content.dialogue.FacialExpression
|
|
||||||
|
|
||||||
class GrimDialogue(player: Player? = null) : DialoguePlugin(player){
|
class GrimDialogue(player: Player? = null) : DialoguePlugin(player){
|
||||||
var firstSpeak = true
|
var firstSpeak = true
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package rs09.game.content.global.worldevents.holiday
|
package rs09.game.content.global.worldevents.holiday.halloween
|
||||||
|
|
||||||
import core.game.node.entity.npc.NPC
|
import core.game.node.entity.npc.NPC
|
||||||
import core.game.world.map.Location
|
import core.game.world.map.Location
|
||||||
|
|
@ -1,59 +1,30 @@
|
||||||
package rs09.game.content.global.worldevents.shootingstar
|
package rs09.game.content.global.worldevents.shootingstar
|
||||||
|
|
||||||
import core.cache.def.impl.ObjectDefinition
|
|
||||||
import core.game.interaction.OptionHandler
|
|
||||||
import core.game.node.Node
|
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.plugin.Plugin
|
|
||||||
import rs09.game.content.global.worldevents.WorldEvents
|
import rs09.game.content.global.worldevents.WorldEvents
|
||||||
import rs09.game.world.GameWorld
|
import rs09.game.interaction.InteractionListener
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Option handlers for the various shooting star objects.
|
* Option handlers for the various shooting star objects.
|
||||||
*/
|
*/
|
||||||
class ShootingStarOptionHandler : OptionHandler() {
|
class ShootingStarOptionHandler : InteractionListener() {
|
||||||
|
|
||||||
override fun newInstance(arg: Any?): Plugin<Any>? {
|
val SHOOTING_STARS = ShootingStarType.values().map(ShootingStarType::objectId).toIntArray()
|
||||||
for (star in ShootingStarType.values()) {
|
|
||||||
ObjectDefinition.forId(star.objectId).handlers["option:mine"] = this
|
|
||||||
ObjectDefinition.forId(star.objectId).handlers["option:prospect"] = this
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun handle(player: Player, node: Node, option: String): Boolean {
|
override fun defineListeners() {
|
||||||
val star: ShootingStar? = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
on(SHOOTING_STARS,OBJECT,"mine"){player, _ ->
|
||||||
star ?: return false
|
val star = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||||
when (option) {
|
|
||||||
"mine" -> {
|
|
||||||
star.mine(player)
|
star.mine(player)
|
||||||
|
return@on true
|
||||||
}
|
}
|
||||||
"prospect" -> {
|
|
||||||
|
on(SHOOTING_STARS,OBJECT,"prospect"){player, _ ->
|
||||||
|
val star = (WorldEvents.get("shooting-stars") as ShootingStarEvent).star
|
||||||
star.prospect(player)
|
star.prospect(player)
|
||||||
}
|
return@on true
|
||||||
"observe" -> if (star.isSpawned) {
|
|
||||||
player.dialogueInterpreter.sendDialogue("A shooting star (Level " + (star.level.ordinal + 1).toString() + ")", "is currently crashed near the " + star.location + ".")
|
|
||||||
} else {
|
|
||||||
val tickDiff = (if (GameWorld.settings?.isDevMode == true) 200 else 7200) - star.ticks
|
|
||||||
val seconds = Math.ceil((tickDiff.toFloat() / 1000.toFloat()) * 600.toDouble()).toInt()
|
|
||||||
val hours = TimeUnit.SECONDS.toHours(seconds.toLong()).toInt()
|
|
||||||
val minutes = TimeUnit.SECONDS.toMinutes(seconds.toLong()).toInt()
|
|
||||||
var time = ""
|
|
||||||
time += if (hours > 0) {
|
|
||||||
"$hours hour"
|
|
||||||
} else {
|
|
||||||
if (minutes > 0) {
|
|
||||||
"$minutes minute(s)"
|
|
||||||
} else {
|
|
||||||
"$seconds second(s)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.dialogueInterpreter.sendDialogue("The next star will crash in approximately:", time)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
companion object {
|
companion object {
|
||||||
const val STAR_DUST = 13727
|
const val STAR_DUST = 13727
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue